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

Method getWorkspaceDocument

internal/server/server.go:4239–4256  ·  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

4237
4238// getWorkspaceDocument resolves workspace slug and document ID from URL params.
4239func (s *Server) getWorkspaceDocument(w http.ResponseWriter, r *http.Request) (string, *models.Document, bool) {
4240 workspaceID, ok := s.getWorkspaceID(w, r)
4241 if !ok {
4242 return "", nil, false
4243 }
4244
4245 docID := chi.URLParam(r, "docID")
4246 doc, err := s.store.GetDocument(docID)
4247 if err != nil {
4248 writeInternalError(w, err)
4249 return "", nil, false
4250 }
4251 if doc == nil || doc.WorkspaceID != workspaceID {
4252 writeError(w, http.StatusNotFound, "not_found", "Document not found")
4253 return "", nil, false
4254 }
4255 return workspaceID, doc, true
4256}

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