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