add acl service
This commit is contained in:
@@ -8,8 +8,10 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
api_acladmin "git.oblat.lv/alex/triggerssmith/api/acl_admin"
|
||||
api_auth "git.oblat.lv/alex/triggerssmith/api/auth"
|
||||
api_block "git.oblat.lv/alex/triggerssmith/api/block"
|
||||
"git.oblat.lv/alex/triggerssmith/internal/acl"
|
||||
"git.oblat.lv/alex/triggerssmith/internal/auth"
|
||||
"git.oblat.lv/alex/triggerssmith/internal/config"
|
||||
"git.oblat.lv/alex/triggerssmith/internal/vars"
|
||||
@@ -23,11 +25,14 @@ type Router struct {
|
||||
cfg *config.Config
|
||||
|
||||
authService *auth.Service
|
||||
|
||||
aclService *acl.Service
|
||||
}
|
||||
|
||||
type RouterDependencies struct {
|
||||
AuthService *auth.Service
|
||||
Configuration *config.Config
|
||||
ACLService *acl.Service
|
||||
}
|
||||
|
||||
func NewRouter(deps RouterDependencies) *Router {
|
||||
@@ -37,11 +42,15 @@ func NewRouter(deps RouterDependencies) *Router {
|
||||
if deps.Configuration == nil {
|
||||
panic("Configuration is required")
|
||||
}
|
||||
if deps.ACLService == nil {
|
||||
panic("ACLService is required")
|
||||
}
|
||||
r := chi.NewRouter()
|
||||
return &Router{
|
||||
r: r,
|
||||
cfg: deps.Configuration,
|
||||
authService: deps.AuthService,
|
||||
aclService: deps.ACLService,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +86,9 @@ func (r *Router) MustRoute() chi.Router {
|
||||
authRoute := api_auth.MustRoute(r.cfg, r.authService)
|
||||
api.Route("/auth", authRoute)
|
||||
api.Route("/users", authRoute) // legacy support
|
||||
aclAdminRoute := api_acladmin.MustRoute(r.cfg, r.aclService, r.authService)
|
||||
api.Route("/acl", aclAdminRoute)
|
||||
api.Route("/acl-admin", aclAdminRoute) // legacy support
|
||||
})
|
||||
|
||||
r.r.Get("/health", func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user