(w http.ResponseWriter, r *http.Request)
| 546 | } |
| 547 | |
| 548 | func (s *Server) handleUpdateWorkspace(w http.ResponseWriter, r *http.Request) { |
| 549 | if !requireMinRole(w, r, "owner") { |
| 550 | return |
| 551 | } |
| 552 | existing, ok := s.getWorkspace(w, r) |
| 553 | if !ok { |
| 554 | return |
| 555 | } |
| 556 | |
| 557 | var input models.WorkspaceUpdate |
| 558 | if err := decodeJSON(r, &input); err != nil { |
| 559 | writeError(w, http.StatusBadRequest, "bad_request", err.Error()) |
| 560 | return |
| 561 | } |
| 562 | if err := normalizeWorkspaceUpdateInput(&input); err != nil { |
| 563 | writeError(w, http.StatusBadRequest, "bad_request", err.Error()) |
| 564 | return |
| 565 | } |
| 566 | |
| 567 | ws, err := s.store.UpdateWorkspace(existing.Slug, input) |
| 568 | if err != nil { |
| 569 | writeInternalError(w, err) |
| 570 | return |
| 571 | } |
| 572 | if ws == nil { |
| 573 | writeError(w, http.StatusNotFound, "not_found", "Workspace not found") |
| 574 | return |
| 575 | } |
| 576 | |
| 577 | s.publishEvent(events.WorkspaceUpdated, ws.ID, "", ws.Name, "", "", "") |
| 578 | |
| 579 | writeJSON(w, http.StatusOK, ws) |
| 580 | } |
| 581 | |
| 582 | func (s *Server) handleDeleteWorkspace(w http.ResponseWriter, r *http.Request) { |
| 583 | if !requireMinRole(w, r, "owner") { |
nothing calls this directly
no test coverage detected