Files
gis/internal/transport/http/router.go
Bakhtiyar Issakhmetov ad3c9fbdcd feat(landscape): HTTP API, worker consumer, wiring, docs
Adds the /landscape routes (slots, slot upload, runs, run detail, results),
mounts them in the router, wires the landscape repository, job publisher,
godal raster IO and Compute into the composition root, and registers the
gis-landscape-runner consumer in the worker.

Also fixes the Dockerfile so the image actually runs: godal's cgo needs g++,
and the runtime base must match the builder's Alpine release or libgdal's
soname does not resolve.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-05 14:11:57 +05:00

49 lines
1.2 KiB
Go

package http
import (
"log/slog"
"net/http"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
)
// RouterDeps holds the handlers and dependencies the router mounts.
type RouterDeps struct {
Logger *slog.Logger
Health *HealthHandler
Categories *CategoryHandler
Datasets *DatasetHandler
// DatasetGroups serves the /dataset-groups routes.
DatasetGroups *DatasetGroupHandler
// Landscape serves the /landscape routes.
Landscape *LandscapeHandler
OpenAPISpec []byte
}
// NewRouter builds the application's HTTP handler with middleware and routes.
func NewRouter(deps RouterDeps) http.Handler {
r := chi.NewRouter()
r.Use(middleware.RequestID)
r.Use(middleware.RealIP)
r.Use(requestLogger(deps.Logger))
r.Use(middleware.Recoverer)
// Health/readiness endpoints.
r.Get("/healthz", deps.Health.Live)
r.Get("/readyz", deps.Health.Ready)
// OpenAPI 3.1.1 spec + Redoc documentation UI.
r.Get("/openapi.yaml", deps.openAPISpec)
r.Get("/docs", docsUI)
// Domain routes. Add future feature routers here.
r.Route("/categories", deps.Categories.Register)
r.Route("/datasets", deps.Datasets.Register)
r.Route("/dataset-groups", deps.DatasetGroups.Register)
r.Route("/landscape", deps.Landscape.Register)
return r
}