b88f88c1a3
- store: DeleteAccount, DeleteTask, UpdateEndpoint (+ cascade/update tests)
- httpapi: DELETE /tasks/{id}, DELETE /tasks/{id}/accounts/{accountId},
PUT /endpoints/{id}; delete guarded with 409 while task running
- orchestrator: enrich WS events with login/host/port/error (test + run + errors)
- web: delete buttons (task, account) with confirm, endpoint edit form,
human-readable event log (source/dest, host:port, error text)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MMHQTtnQtQqL8muAXHr9kd
34 lines
1.3 KiB
Go
34 lines
1.3 KiB
Go
package httpapi
|
|
|
|
import "net/http"
|
|
|
|
func (s *Server) Router() http.Handler {
|
|
mux := http.NewServeMux()
|
|
|
|
// открытые
|
|
mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) })
|
|
mux.HandleFunc("POST /api/login", s.handleLogin)
|
|
mux.HandleFunc("POST /api/logout", s.handleLogout)
|
|
|
|
// защищённые
|
|
api := http.NewServeMux()
|
|
api.HandleFunc("GET /api/endpoints", s.handleListEndpoints)
|
|
api.HandleFunc("POST /api/endpoints", s.handleCreateEndpoint)
|
|
api.HandleFunc("PUT /api/endpoints/{id}", s.handleUpdateEndpoint)
|
|
api.HandleFunc("GET /api/tasks", s.handleListTasks)
|
|
api.HandleFunc("POST /api/tasks", s.handleCreateTask)
|
|
api.HandleFunc("GET /api/tasks/{id}", s.handleGetTask)
|
|
api.HandleFunc("DELETE /api/tasks/{id}", s.handleDeleteTask)
|
|
api.HandleFunc("POST /api/tasks/{id}/accounts", s.handleCreateAccount)
|
|
api.HandleFunc("DELETE /api/tasks/{id}/accounts/{accountId}", s.handleDeleteAccount)
|
|
api.HandleFunc("POST /api/tasks/{id}/import", s.handleImportCSV)
|
|
api.HandleFunc("POST /api/tasks/{id}/test", s.handleTestAccounts)
|
|
api.HandleFunc("POST /api/tasks/{id}/run", s.handleRun)
|
|
mux.Handle("/api/", s.requireAuth(api))
|
|
mux.Handle("/ws", s.requireAuth(http.HandlerFunc(s.handleWS)))
|
|
|
|
// SPA static (fallback)
|
|
mux.Handle("/", s.staticHandler())
|
|
return mux
|
|
}
|