isUUID is defined in handlers_items.go getWorkspaceDocument resolves workspace slug and document ID from URL params.
(w http.ResponseWriter, r *http.Request)
| 2418 | |
| 2419 | // getWorkspaceDocument resolves workspace slug and document ID from URL params. |
| 2420 | func (s *Server) getWorkspaceDocument(w http.ResponseWriter, r *http.Request) (string, *models.Document, bool) { |
| 2421 | workspaceID, ok := s.getWorkspaceID(w, r) |
| 2422 | if !ok { |
| 2423 | return "", nil, false |
| 2424 | } |
| 2425 | |
| 2426 | docID := chi.URLParam(r, "docID") |
| 2427 | doc, err := s.store.GetDocument(docID) |
| 2428 | if err != nil { |
| 2429 | writeInternalError(w, err) |
| 2430 | return "", nil, false |
| 2431 | } |
| 2432 | if doc == nil || doc.WorkspaceID != workspaceID { |
| 2433 | writeError(w, http.StatusNotFound, "not_found", "Document not found") |
| 2434 | return "", nil, false |
| 2435 | } |
| 2436 | return workspaceID, doc, true |
| 2437 | } |
no test coverage detected