isUUID is defined in handlers_items.go getWorkspaceDocument resolves workspace slug and document ID from URL params.
(w http.ResponseWriter, r *http.Request)
| 2513 | |
| 2514 | // getWorkspaceDocument resolves workspace slug and document ID from URL params. |
| 2515 | func (s *Server) getWorkspaceDocument(w http.ResponseWriter, r *http.Request) (string, *models.Document, bool) { |
| 2516 | workspaceID, ok := s.getWorkspaceID(w, r) |
| 2517 | if !ok { |
| 2518 | return "", nil, false |
| 2519 | } |
| 2520 | |
| 2521 | docID := chi.URLParam(r, "docID") |
| 2522 | doc, err := s.store.GetDocument(docID) |
| 2523 | if err != nil { |
| 2524 | writeInternalError(w, err) |
| 2525 | return "", nil, false |
| 2526 | } |
| 2527 | if doc == nil || doc.WorkspaceID != workspaceID { |
| 2528 | writeError(w, http.StatusNotFound, "not_found", "Document not found") |
| 2529 | return "", nil, false |
| 2530 | } |
| 2531 | return workspaceID, doc, true |
| 2532 | } |
no test coverage detected