diff --git a/api/auth/handle.go b/api/auth/handle.go index 39af05e..df86892 100644 --- a/api/auth/handle.go +++ b/api/auth/handle.go @@ -13,7 +13,10 @@ type authHandler struct { cfg *config.Config } -func Route(config *config.Config) func(chi.Router) { +func MustRoute(config *config.Config) func(chi.Router) { + if config == nil { + panic("config is nil") + } h := &authHandler{ cfg: config, } @@ -31,4 +34,4 @@ func (h *authHandler) handleLogout(w http.ResponseWriter, r *http.Request) {} func (h *authHandler) handleMe(w http.ResponseWriter, r *http.Request) {} -func (h *authHandler) handleRevoke(w http.ResponseWriter, r *http.Request) {} \ No newline at end of file +func (h *authHandler) handleRevoke(w http.ResponseWriter, r *http.Request) {} diff --git a/api/block/handle.go b/api/block/handle.go index f1bc517..ef8b7bd 100644 --- a/api/block/handle.go +++ b/api/block/handle.go @@ -29,7 +29,10 @@ type blockHandler struct { cfg *config.Config } -func Route(config *config.Config) func(chi.Router) { +func MustRoute(config *config.Config) func(chi.Router) { + if config == nil { + panic("config is nil") + } h := &blockHandler{ cfg: config, } diff --git a/api/router.go b/api/router.go index de8d287..506e541 100644 --- a/api/router.go +++ b/api/router.go @@ -32,7 +32,7 @@ func NewRouter(cfg *config.Config) *Router { // RouteHandler sets up the routes and middleware for the router. // TODO: implement hot reload for static files enabled/disabled -func (r *Router) RouteHandler() chi.Router { +func (r *Router) MustRoute() chi.Router { r.r.Use(middleware.Logger) r.r.Use(middleware.Recoverer) r.r.Use(middleware.Timeout(r.cfg.Server.TimeoutSeconds)) @@ -58,8 +58,8 @@ func (r *Router) RouteHandler() chi.Router { } r.r.Route("/api", func(api chi.Router) { - api.Route("/block", block.Route(r.cfg)) - api.Route("/auth", auth.Route(r.cfg)) + api.Route("/block", block.MustRoute(r.cfg)) + api.Route("/auth", auth.MustRoute(r.cfg)) }) r.r.Get("/health", func(w http.ResponseWriter, r *http.Request) {