isUUID is defined in handlers_items.go getWorkspaceDocument resolves workspace slug and document ID from URL params.
(w http.ResponseWriter, r *http.Request)
| 4237 | |
| 4238 | // getWorkspaceDocument resolves workspace slug and document ID from URL params. |
| 4239 | func (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 | } |
no test coverage detected