MCPcopy
hub / github.com/ZenNotes/zennotes / selectVault

Method selectVault

apps/server/internal/httpserver/server.go:340–367  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

338}
339
340func (s *Server) selectVault(w http.ResponseWriter, r *http.Request) {
341 if osPath := strings.TrimSpace(os.Getenv("ZENNOTES_VAULT_PATH")); osPath != "" {
342 http.Error(w, "vault path is managed by ZENNOTES_VAULT_PATH", http.StatusConflict)
343 return
344 }
345 var req struct {
346 Path string `json:"path"`
347 }
348 if err := readJSON(r, &req); err != nil {
349 http.Error(w, err.Error(), http.StatusBadRequest)
350 return
351 }
352 if strings.TrimSpace(req.Path) == "" {
353 http.Error(w, "vault path is required", http.StatusBadRequest)
354 return
355 }
356 allowedPath, err := s.ensureBrowsePathAllowed(req.Path)
357 if err != nil {
358 writeError(w, err)
359 return
360 }
361 nextVault, err := s.switchVaultRoot(allowedPath)
362 if err != nil {
363 writeError(w, err)
364 return
365 }
366 writeJSON(w, http.StatusOK, nextVault.Info())
367}
368
369type directoryBrowseEntry struct {
370 Name string `json:"name"`

Callers

nothing calls this directly

Calls 7

switchVaultRootMethod · 0.95
readJSONFunction · 0.85
writeErrorFunction · 0.85
writeJSONFunction · 0.85
ErrorMethod · 0.80
InfoMethod · 0.80

Tested by

no test coverage detected