package http import ( "log/slog" "net/http" "net/http/pprof" "git.loyso.art/frx/devsim/internal/probe" "git.loyso.art/frx/devsim/internal/store" ) type handlersBuilder struct { mux *http.ServeMux } func NewHandlersBuilder() *handlersBuilder { return &handlersBuilder{ mux: http.NewServeMux(), } } // MountStatsHandlers mounts stats related handlers. func (h *handlersBuilder) MountStatsHandlers(sr store.Stats, log *slog.Logger) { // log = log.With(slog.String("api", "http")) // mws := multipleMiddlewares( // middlewarePanicRecovery(log), // middlewareLogger(log), // ) h.mux.Handle("/api/v1/stats/", listStatsHandler(sr)) h.mux.Handle("/api/v1/stats/{id}", postStatsHandler(sr)) } func (s *handlersBuilder) MountProfileHandlers() { s.mux.HandleFunc("/debug/pprof", pprof.Index) s.mux.HandleFunc("/debug/pprof/profile", pprof.Profile) s.mux.HandleFunc("/debug/pprof/trace", pprof.Trace) } func (s *handlersBuilder) MountProbeHandlers(r probe.Reporter) { s.mux.HandleFunc("/health", livenessHandler(r)) s.mux.HandleFunc("/ready", readinessHandler(r)) } func (s *handlersBuilder) Build() http.Handler { return s.mux }