woj-server/internal/web/router/api.go

36 lines
1.3 KiB
Go
Raw Normal View History

2022-09-07 23:34:37 +08:00
package router
import (
2023-07-14 21:47:11 +08:00
"git.0x7f.app/WOJ/woj-server/internal/api/debug"
2024-01-05 00:57:43 +08:00
"git.0x7f.app/WOJ/woj-server/internal/api/oauth"
2023-07-14 21:47:11 +08:00
"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"
2023-07-15 16:19:49 +08:00
"git.0x7f.app/WOJ/woj-server/internal/model"
2022-09-07 23:34:37 +08:00
"github.com/gin-gonic/gin"
2023-07-15 16:19:49 +08:00
"github.com/samber/do"
2022-09-07 23:34:37 +08:00
)
// @title WOJ Server API Documentation
2023-12-22 15:38:44 +08:00
// @version 1.2.0
2022-09-17 11:22:55 +08:00
// @BasePath /api
// @securityDefinitions.apikey Authentication
// @in header
// @name Authorization
2023-07-15 16:19:49 +08:00
func (s *service) setupApi(root *gin.RouterGroup, injector *do.Injector) {
2022-09-07 23:34:37 +08:00
for _, v := range endpoints {
group := root.Group(v.Version).Group(v.Path)
2023-07-15 16:19:49 +08:00
v.Register(group, injector)
2022-09-07 23:34:37 +08:00
}
}
2023-07-15 16:19:49 +08:00
var endpoints = []model.EndpointInfo{
2022-09-07 23:34:37 +08:00
{Version: "", Path: "/debug", Register: debug.RouteRegister},
2022-09-08 22:00:25 +08:00
{Version: "/v1", Path: "/user", Register: user.RouteRegister},
2022-09-26 16:13:31 +08:00
{Version: "/v1", Path: "/problem", Register: problem.RouteRegister},
{Version: "/v1", Path: "/submission", Register: submission.RouteRegister},
{Version: "/v1", Path: "/status", Register: status.RouteRegister},
2024-01-05 00:57:43 +08:00
{Version: "/v1", Path: "/oauth", Register: oauth.RouteRegister},
2022-09-07 23:34:37 +08:00
}