Files
acc-server-manager/local/api/api.go
Fran Jurmanović 60175f8052
Some checks failed
Release and Deploy / build (push) Failing after 2m11s
Release and Deploy / deploy (push) Has been skipped
2fa for polling and security
2025-08-16 16:21:39 +02:00

49 lines
1.2 KiB
Go

package api
import (
"acc-server-manager/local/controller"
"acc-server-manager/local/middleware"
"acc-server-manager/local/utl/common"
"acc-server-manager/local/utl/configs"
"acc-server-manager/local/utl/logging"
"github.com/gofiber/fiber/v2"
"go.uber.org/dig"
)
// Routes
// Initializes web api controllers and its corresponding routes.
//
// Args:
// *fiber.App: Fiber Application
func Init(di *dig.Container, app *fiber.App) {
// Protected routes
groups := app.Group(configs.Prefix)
serverIdGroup := groups.Group("/server/:id")
routeGroups := &common.RouteGroups{
Api: groups.Group("/api"),
Auth: groups.Group("/auth"),
Server: groups.Group("/server"),
Config: serverIdGroup.Group("/config"),
Lookup: groups.Group("/lookup"),
StateHistory: serverIdGroup.Group("/state-history"),
Membership: groups.Group("/membership"),
System: groups.Group("/system"),
Steam2FA: groups.Group("/steam2fa"),
}
accessKeyMiddleware := middleware.NewAccessKeyMiddleware()
routeGroups.Api.Use(accessKeyMiddleware.Authenticate)
err := di.Provide(func() *common.RouteGroups {
return routeGroups
})
if err != nil {
logging.Panic("unable to bind routes")
}
controller.InitializeControllers(di)
}