isUUID is defined in handlers_items.go getWorkspaceDocument resolves workspace slug and document ID from URL params.
(w http.ResponseWriter, r *http.Request)
| 2836 | |
| 2837 | // getWorkspaceDocument resolves workspace slug and document ID from URL params. |
| 2838 | func (s *Server) getWorkspaceDocument(w http.ResponseWriter, r *http.Request) (string, *models.Document, bool) { |
| 2839 | workspaceID, ok := s.getWorkspaceID(w, r) |
| 2840 | if !ok { |
| 2841 | return "", nil, false |
| 2842 | } |
| 2843 | |
| 2844 | docID := chi.URLParam(r, "docID") |
| 2845 | doc, err := s.store.GetDocument(docID) |
| 2846 | if err != nil { |
| 2847 | writeInternalError(w, err) |
| 2848 | return "", nil, false |
| 2849 | } |
| 2850 | if doc == nil || doc.WorkspaceID != workspaceID { |
| 2851 | writeError(w, http.StatusNotFound, "not_found", "Document not found") |
| 2852 | return "", nil, false |
| 2853 | } |
| 2854 | return workspaceID, doc, true |
| 2855 | } |
no test coverage detected