feat: endpoints de mutacion y de projects

- handlers_mutations.go: POST add_app/add_analysis/add_vault/reindex
- handlers_projects.go: GET projects y project detail (apps/analysis/vaults nested)
- handlers.go + main.go: cablear nuevas rutas
- handlers_test.go: ajustes minimos
- app.md: documentar endpoints v0.2

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Egutierrez
2026-04-28 22:05:08 +02:00
parent 1dc09931b6
commit af13fd849c
6 changed files with 551 additions and 11 deletions
+14 -3
View File
@@ -13,11 +13,12 @@ const queryTimeout = 5 * time.Second
// Server holds the HTTP handlers and DB pool.
type Server struct {
pool *DBPool
pool *DBPool
registryRoot string // raiz del fn_registry (para exec fn ...)
}
func NewServer(pool *DBPool) *Server {
return &Server{pool: pool}
func NewServer(pool *DBPool, registryRoot string) *Server {
return &Server{pool: pool, registryRoot: registryRoot}
}
// Routes registers all API routes on the given mux.
@@ -28,6 +29,16 @@ func (s *Server) Routes(mux *http.ServeMux) {
mux.HandleFunc("GET /api/databases/{db}/schema", s.handleSchema)
mux.HandleFunc("POST /api/databases/{db}/query", s.handleQuery)
mux.HandleFunc("GET /api/databases/{db}/fts", s.handleFTS)
// Projects: listado con conteos + detalle nested
mux.HandleFunc("GET /api/projects", s.handleProjects)
mux.HandleFunc("GET /api/projects/{id}", s.handleProjectDetail)
// Mutaciones: reindex + add (apps/analysis/vaults)
mux.HandleFunc("POST /api/reindex", s.handleReindex)
mux.HandleFunc("POST /api/add/app", s.handleAddApp)
mux.HandleFunc("POST /api/add/analysis", s.handleAddAnalysis)
mux.HandleFunc("POST /api/add/vault", s.handleAddVault)
}
func (s *Server) handleHealth(w http.ResponseWriter, r *http.Request) {