1package web23import (4 "context"5 "net/http"67 "charm.land/log/v2"8 "github.com/charmbracelet/soft-serve/pkg/config"9 "github.com/gorilla/handlers"10 "github.com/gorilla/mux"11)1213// NewRouter returns a new HTTP router.14func NewRouter(ctx context.Context) http.Handler {15 logger := log.FromContext(ctx).WithPrefix("http")16 router := mux.NewRouter()1718 // Health routes19 HealthController(ctx, router)2021 // Git routes22 GitController(ctx, router)2324 router.PathPrefix("/").HandlerFunc(renderNotFound)2526 // Context handler27 // Adds context to the request28 h := NewLoggingMiddleware(router, logger)29 h = NewContextHandler(ctx)(h)30 h = handlers.CompressHandler(h)31 h = handlers.RecoveryHandler()(h)3233 cfg := config.FromContext(ctx)3435 h = handlers.CORS(handlers.AllowedHeaders(cfg.HTTP.CORS.AllowedHeaders),36 handlers.AllowedOrigins(cfg.HTTP.CORS.AllowedOrigins),37 handlers.AllowedMethods(cfg.HTTP.CORS.AllowedMethods),38 )(h)3940 return h41}