add auth service to main router's deps
This commit is contained in:
@@ -8,8 +8,9 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.oblat.lv/alex/triggerssmith/api/auth"
|
api_auth "git.oblat.lv/alex/triggerssmith/api/auth"
|
||||||
"git.oblat.lv/alex/triggerssmith/api/block"
|
api_block "git.oblat.lv/alex/triggerssmith/api/block"
|
||||||
|
"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"
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
@@ -20,13 +21,27 @@ type Router struct {
|
|||||||
r chi.Router
|
r chi.Router
|
||||||
|
|
||||||
cfg *config.Config
|
cfg *config.Config
|
||||||
|
|
||||||
|
authService *auth.AuthService
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRouter(cfg *config.Config) *Router {
|
type RouterDependencies struct {
|
||||||
|
AuthService *auth.AuthService
|
||||||
|
Configuration *config.Config
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRouter(deps RouterDependencies) *Router {
|
||||||
|
if deps.AuthService == nil {
|
||||||
|
panic("AuthService is required")
|
||||||
|
}
|
||||||
|
if deps.Configuration == nil {
|
||||||
|
panic("Configuration is required")
|
||||||
|
}
|
||||||
r := chi.NewRouter()
|
r := chi.NewRouter()
|
||||||
return &Router{
|
return &Router{
|
||||||
r: r,
|
r: r,
|
||||||
cfg: cfg,
|
cfg: deps.Configuration,
|
||||||
|
authService: deps.AuthService,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user