package oauth import ( "gitea.local/admin/hspguard/internal/config" imiddleware "gitea.local/admin/hspguard/internal/middleware" "gitea.local/admin/hspguard/internal/repository" "github.com/go-chi/chi/v5" ) type OAuthHandler struct { repo *repository.Queries cfg *config.AppConfig } func NewOAuthHandler(repo *repository.Queries, cfg *config.AppConfig) *OAuthHandler { return &OAuthHandler{ repo, cfg, } } func (h *OAuthHandler) RegisterRoutes(router chi.Router) { router.Route("/oauth", func(r chi.Router) { r.Group(func(protected chi.Router) { authMiddleware := imiddleware.NewAuthMiddleware(h.cfg) protected.Use(authMiddleware.Runner) protected.Post("/code", h.getAuthCode) }) r.Get("/authorize", h.AuthorizeClient) r.Post("/token", h.tokenEndpoint) }) }