3
0
Files
corteza/system/rest/router.go
Denis Arh 980b6d581c Refactor JWT encoder/handler
Handler is no longer passed as argument into routes etc but initialized in the Init()
and stored into auth.DefaultJwtHandler.
2019-04-27 13:17:37 +02:00

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)
})
}
}