mirror of
https://github.com/Dvorinka/SEEN.git
synced 2026-06-04 12:33:02 +00:00
small fix, don't worry about it
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tdvorak/seen/backend/internal/api/handlers"
|
||||
v1 "github.com/tdvorak/seen/backend/internal/api/routes/v1"
|
||||
"github.com/tdvorak/seen/backend/internal/config"
|
||||
"github.com/tdvorak/seen/backend/internal/middleware"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type Handlers struct {
|
||||
Health *handlers.HealthHandler
|
||||
Auth *handlers.AuthHandler
|
||||
Catalog *handlers.CatalogHandler
|
||||
Download *handlers.DownloadHandler
|
||||
Placeholder *handlers.PlaceholderHandler
|
||||
}
|
||||
|
||||
func NewRouter(cfg config.Config, log *zap.Logger, handlers Handlers) *gin.Engine {
|
||||
if cfg.Env == "production" {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
|
||||
engine := gin.New()
|
||||
engine.Use(middleware.RequestID())
|
||||
engine.Use(middleware.CORS(cfg.CORS))
|
||||
engine.Use(middleware.AccessLog(log))
|
||||
engine.Use(middleware.Recovery(log))
|
||||
|
||||
engine.GET("/healthz", handlers.Health.Live)
|
||||
|
||||
apiV1 := engine.Group("/api/v1")
|
||||
v1.Register(apiV1, handlers.Health, handlers.Auth, handlers.Catalog, handlers.Download, handlers.Placeholder)
|
||||
|
||||
return engine
|
||||
}
|
||||
Reference in New Issue
Block a user