-
Notifications
You must be signed in to change notification settings - Fork 0
/
inject.go
36 lines (28 loc) · 1.19 KB
/
inject.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
package server
import (
"github.com/gin-gonic/gin"
"github.com/spring-financial-group/peacock/pkg/config"
"github.com/spring-financial-group/peacock/pkg/git/github"
"github.com/spring-financial-group/peacock/pkg/health"
"github.com/spring-financial-group/peacock/pkg/logger"
"github.com/spring-financial-group/peacock/pkg/releasenotes/delivery/msgclients"
releasenotesuc "github.com/spring-financial-group/peacock/pkg/releasenotes/usecase"
"github.com/spring-financial-group/peacock/pkg/webhook/handler"
"github.com/spring-financial-group/peacock/pkg/webhook/usecase"
)
func inject(cfg *config.Config, sources *DataSources) (*gin.Engine, error) {
// Setup router
gin.SetMode(gin.ReleaseMode)
router := gin.New()
publicGroup := router.Group("/")
publicGroup.Use(logger.Middleware())
infraGroup := router.Group("/")
scmFactory := github.NewClientFactory(cfg.SCM.Token)
msgHandler := msgclients.NewMessageHandler(&cfg.MessageHandlers)
notesUC := releasenotesuc.NewUseCase(msgHandler)
webhookUC := webhookuc.NewUseCase(&cfg.SCM, scmFactory, notesUC)
// Setup handlers
webhookhandler.NewHandler(&cfg.SCM, publicGroup, webhookUC)
infraGroup.GET("/health", health.ServeHealth)
return router, nil
}