From 8de6a9212aa79c491583d695042428a2dcf7f658 Mon Sep 17 00:00:00 2001 From: Alexey Date: Thu, 18 Dec 2025 09:48:14 +0200 Subject: [PATCH] add auth service to main router's deps --- api/router.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/api/router.go b/api/router.go index 3215626..e759eda 100644 --- a/api/router.go +++ b/api/router.go @@ -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, + r: r, + cfg: deps.Configuration, + authService: deps.AuthService, } }