package main import ( "github.com/jackc/pgx/v5/pgxpool" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" "osdb/internal/handler" ) // New creates and configures the Echo instance with all routes registered. // pool is stored on Echo's context so all handlers added by future stories // (#2 fruits, #4 publications, #7 thumbnails, #8 auth) can retrieve it via // c.Get("pool").(*pgxpool.Pool). // // Extension point: story #2, #4, #7, #8 route groups are added here. func New(pool *pgxpool.Pool) *echo.Echo { e := echo.New() e.HideBanner = true // Global middleware e.Use(middleware.Logger()) e.Use(middleware.Recover()) // Make pool available to all handlers via Echo context. e.Use(func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { c.Set("pool", pool) return next(c) } }) health := handler.NewHealthHandler() // Root health — used by docker healthcheck + ops tooling e.GET("/health", health.Health) // Versioned API group api := e.Group("/api/v1") api.GET("/health", health.Health) // Future story groups (fruits, publications, admin, auth) are added here. return e }