package server import ( "encoding/json" "net/http" ) type renamePreviewResponse struct { Targets []string `json:"targets"` } func (s *Server) handleRenamePreview(w http.ResponseWriter, r *http.Request) { if !requirePathMutationPost(w, r) { return } snapshot, err := s.authorizedMutationSnapshot(r, "rename", "", r.URL.Query().Get("old_path"), "", true) if err != nil { writePathMutationError(w, err) return } // Return the checked set, not a fresh query that could reveal a newly added // descendant for which the requester has never been authorized. w.Header().Set("Content-Type", "application/json") _ = json.NewEncoder(w).Encode(renamePreviewResponse{Targets: snapshot.Paths()}) }