MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / getWorkspaceDocument

Method getWorkspaceDocument

internal/server/server.go:2428–2445  ·  view source on GitHub ↗

isUUID is defined in handlers_items.go getWorkspaceDocument resolves workspace slug and document ID from URL params.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

2426
2427// getWorkspaceDocument resolves workspace slug and document ID from URL params.
2428func (s *Server) getWorkspaceDocument(w http.ResponseWriter, r *http.Request) (string, *models.Document, bool) {
2429 workspaceID, ok := s.getWorkspaceID(w, r)
2430 if !ok {
2431 return "", nil, false
2432 }
2433
2434 docID := chi.URLParam(r, "docID")
2435 doc, err := s.store.GetDocument(docID)
2436 if err != nil {
2437 writeInternalError(w, err)
2438 return "", nil, false
2439 }
2440 if doc == nil || doc.WorkspaceID != workspaceID {
2441 writeError(w, http.StatusNotFound, "not_found", "Document not found")
2442 return "", nil, false
2443 }
2444 return workspaceID, doc, true
2445}

Callers 6

handleGetDocumentMethod · 0.95
handleUpdateDocumentMethod · 0.95
handleDeleteDocumentMethod · 0.95
handleListVersionsMethod · 0.95
handleGetVersionMethod · 0.95

Calls 4

getWorkspaceIDMethod · 0.95
writeInternalErrorFunction · 0.85
writeErrorFunction · 0.85
GetDocumentMethod · 0.80

Tested by

no test coverage detected