Fix mount
This commit is contained in:
parent
22c4afadb6
commit
0204cab4d5
3 changed files with 5 additions and 11 deletions
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue