Fix mount

This commit is contained in:
Daniel 2024-08-03 00:16:23 -04:00
parent 22c4afadb6
commit 0204cab4d5
3 changed files with 5 additions and 11 deletions

View file

@ -29,7 +29,7 @@ type jwtAuth interface {
AuthMiddleware() func(http.Handler) http.Handler AuthMiddleware() func(http.Handler) http.Handler
// InstallRoutes installs the auth route to the provided chi Router. // InstallRoutes installs the auth route to the provided chi Router.
Routes() chi.Router PublicRoutes(chi.Router)
} }
type claims map[string]interface{} type claims map[string]interface{}
@ -89,11 +89,8 @@ func (a *authenticator) newToken(uid int32) string {
return tokenString return tokenString
} }
func (a *authenticator) Routes() chi.Router { func (a *authenticator) PublicRoutes(r chi.Router) {
r := chi.NewRouter()
r.Post("/auth", a.routeAuth) r.Post("/auth", a.routeAuth)
return r
} }
func (a *authenticator) routeAuth(w http.ResponseWriter, r *http.Request) { func (a *authenticator) routeAuth(w http.ResponseWriter, r *http.Request) {

View file

@ -24,8 +24,8 @@ func (s *Server) setupRoutes() {
r.Use(rateLimiter()) r.Use(rateLimiter())
r.Use(render.SetContentType(render.ContentTypeJSON)) r.Use(render.SetContentType(render.ContentTypeJSON))
// public routes // public routes
r.Mount("/", s.auth.Routes()) s.auth.PublicRoutes(r)
r.Mount("/", s.sources.PublicRoutes()) s.sources.PublicRoutes(r)
}) })
r.Group(func(r chi.Router) { r.Group(func(r chi.Router) {

View file

@ -26,15 +26,12 @@ func (s *Sources) Register(name string, src Source) {
}) })
} }
func (s *Sources) PublicRoutes() chi.Router { func (s *Sources) PublicRoutes(r chi.Router) {
r := chi.NewRouter()
for _, si := range *s { for _, si := range *s {
if rs, ok := si.Source.(PublicRouteSource); ok { if rs, ok := si.Source.(PublicRouteSource); ok {
rs.InstallPublicRoutes(r) rs.InstallPublicRoutes(r)
} }
} }
return r
} }
type Ingestor interface { type Ingestor interface {