diff --git a/pkg/gordio/auth/jwt.go b/pkg/gordio/auth/jwt.go index 0ea4087..710f4fc 100644 --- a/pkg/gordio/auth/jwt.go +++ b/pkg/gordio/auth/jwt.go @@ -29,7 +29,7 @@ type jwtAuth interface { AuthMiddleware() func(http.Handler) http.Handler // InstallRoutes installs the auth route to the provided chi Router. - Routes() chi.Router + PublicRoutes(chi.Router) } type claims map[string]interface{} @@ -89,11 +89,8 @@ func (a *authenticator) newToken(uid int32) string { return tokenString } -func (a *authenticator) Routes() chi.Router { - r := chi.NewRouter() +func (a *authenticator) PublicRoutes(r chi.Router) { r.Post("/auth", a.routeAuth) - - return r } func (a *authenticator) routeAuth(w http.ResponseWriter, r *http.Request) { diff --git a/pkg/gordio/server/routes.go b/pkg/gordio/server/routes.go index 71d059c..40180e8 100644 --- a/pkg/gordio/server/routes.go +++ b/pkg/gordio/server/routes.go @@ -24,8 +24,8 @@ func (s *Server) setupRoutes() { r.Use(rateLimiter()) r.Use(render.SetContentType(render.ContentTypeJSON)) // public routes - r.Mount("/", s.auth.Routes()) - r.Mount("/", s.sources.PublicRoutes()) + s.auth.PublicRoutes(r) + s.sources.PublicRoutes(r) }) r.Group(func(r chi.Router) { diff --git a/pkg/gordio/sources/source.go b/pkg/gordio/sources/source.go index 63d4dae..3390adc 100644 --- a/pkg/gordio/sources/source.go +++ b/pkg/gordio/sources/source.go @@ -26,15 +26,12 @@ func (s *Sources) Register(name string, src Source) { }) } -func (s *Sources) PublicRoutes() chi.Router { - r := chi.NewRouter() +func (s *Sources) PublicRoutes(r chi.Router) { for _, si := range *s { if rs, ok := si.Source.(PublicRouteSource); ok { rs.InstallPublicRoutes(r) } } - - return r } type Ingestor interface {