woj-server/internal/web/router/api.go
2023-12-22 15:38:44 +08:00

34 lines
1.2 KiB
Go

package router
import (
"git.0x7f.app/WOJ/woj-server/internal/api/debug"
"git.0x7f.app/WOJ/woj-server/internal/api/problem"
"git.0x7f.app/WOJ/woj-server/internal/api/status"
"git.0x7f.app/WOJ/woj-server/internal/api/submission"
"git.0x7f.app/WOJ/woj-server/internal/api/user"
"git.0x7f.app/WOJ/woj-server/internal/model"
"github.com/gin-gonic/gin"
"github.com/samber/do"
)
// @title WOJ Server API Documentation
// @version 1.2.0
// @BasePath /api
// @securityDefinitions.apikey Authentication
// @in header
// @name Authorization
func (s *service) setupApi(root *gin.RouterGroup, injector *do.Injector) {
for _, v := range endpoints {
group := root.Group(v.Version).Group(v.Path)
v.Register(group, injector)
}
}
var endpoints = []model.EndpointInfo{
{Version: "", Path: "/debug", Register: debug.RouteRegister},
{Version: "/v1", Path: "/user", Register: user.RouteRegister},
{Version: "/v1", Path: "/problem", Register: problem.RouteRegister},
{Version: "/v1", Path: "/submission", Register: submission.RouteRegister},
{Version: "/v1", Path: "/status", Register: status.RouteRegister},
}