Handler is no longer passed as argument into routes etc but initialized in the Init() and stored into auth.DefaultJwtHandler.
33 lines
891 B
Go
33 lines
891 B
Go
package rest
|
|
|
|
import (
|
|
"github.com/go-chi/chi"
|
|
|
|
"github.com/crusttech/crust/internal/auth"
|
|
"github.com/crusttech/crust/system/rest/handlers"
|
|
)
|
|
|
|
func MountRoutes() func(chi.Router) {
|
|
// Initialize handers & controllers.
|
|
return func(r chi.Router) {
|
|
NewSocial().MountRoutes(r)
|
|
|
|
// Provide raw `/auth` handlers
|
|
handlers.NewAuth((Auth{}).New()).MountRoutes(r)
|
|
|
|
handlers.NewAuthInternal((AuthInternal{}).New()).MountRoutes(r)
|
|
|
|
// Protect all _private_ routes
|
|
r.Group(func(r chi.Router) {
|
|
r.Use(auth.MiddlewareValidOnly)
|
|
|
|
handlers.NewUser(User{}.New()).MountRoutes(r)
|
|
handlers.NewRole(Role{}.New()).MountRoutes(r)
|
|
handlers.NewOrganisation(Organisation{}.New()).MountRoutes(r)
|
|
handlers.NewPermissions(Permissions{}.New()).MountRoutes(r)
|
|
handlers.NewApplication(Application{}.New()).MountRoutes(r)
|
|
handlers.NewSettings(Settings{}.New()).MountRoutes(r)
|
|
})
|
|
}
|
|
}
|