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