-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.go
45 lines (37 loc) · 1.05 KB
/
router.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package api
import (
"github.com/acs-dl/auth-svc/internal/data/postgres"
"github.com/acs-dl/auth-svc/internal/service/api/handlers"
"github.com/go-chi/chi"
"gitlab.com/distributed_lab/ape"
)
func (s *service) router() chi.Router {
r := chi.NewRouter()
r.Use(
ape.RecoverMiddleware(s.log),
ape.LoganMiddleware(s.log),
ape.CtxMiddleware(
handlers.CtxLog(s.log),
handlers.CtxJwtParams(*s.cfg.JwtParams()),
handlers.CtxUsersQ(postgres.NewUsersQ(s.cfg.DB())),
handlers.CtxModulesQ(postgres.NewModulesQ(s.cfg.DB())),
handlers.CtxPermissionsQ(postgres.NewPermissionsQ(s.cfg.DB())),
handlers.CtxRefreshTokensQ(postgres.NewRefreshTokensQ(s.cfg.DB())),
),
)
r.Route("/integrations/auth", func(r chi.Router) {
r.Route("/login", func(r chi.Router) {
r.Post("/", handlers.Login)
})
r.Route("/refresh", func(r chi.Router) {
r.Post("/", handlers.Refresh)
})
r.Route("/logout", func(r chi.Router) {
r.Post("/", handlers.Logout)
})
r.Route("/validate", func(r chi.Router) {
r.Post("/", handlers.Validate)
})
})
return r
}