238 lines
5.3 KiB
Go
238 lines
5.3 KiB
Go
|
|
// Code generated by goctl. DO NOT EDIT.
|
||
|
|
// goctl 1.7.6
|
||
|
|
|
||
|
|
package handler
|
||
|
|
|
||
|
|
import (
|
||
|
|
"net/http"
|
||
|
|
|
||
|
|
admin "apps/backend/internal/handler/admin"
|
||
|
|
auth "apps/backend/internal/handler/auth"
|
||
|
|
media "apps/backend/internal/handler/media"
|
||
|
|
ping "apps/backend/internal/handler/ping"
|
||
|
|
settings "apps/backend/internal/handler/settings"
|
||
|
|
"apps/backend/internal/svc"
|
||
|
|
|
||
|
|
"github.com/zeromicro/go-zero/rest"
|
||
|
|
)
|
||
|
|
|
||
|
|
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||
|
|
server.AddRoutes(
|
||
|
|
rest.WithMiddlewares(
|
||
|
|
[]rest.Middleware{serverCtx.AuthJWT, serverCtx.AdminAuth},
|
||
|
|
[]rest.Route{
|
||
|
|
{
|
||
|
|
Method: http.MethodGet,
|
||
|
|
Path: "/members",
|
||
|
|
Handler: admin.ListMembersHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/members",
|
||
|
|
Handler: admin.CreateMemberHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodGet,
|
||
|
|
Path: "/members/:uid",
|
||
|
|
Handler: admin.GetMemberHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/members/:uid/email-verified",
|
||
|
|
Handler: admin.SetEmailVerifiedHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodGet,
|
||
|
|
Path: "/members/:uid/identities",
|
||
|
|
Handler: admin.ListMemberIdentitiesHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/members/:uid/reset-password",
|
||
|
|
Handler: admin.AdminResetPasswordHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/members/:uid/roles",
|
||
|
|
Handler: admin.SetRolesHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/members/:uid/status",
|
||
|
|
Handler: admin.SetStatusHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/members/:uid/suspend",
|
||
|
|
Handler: admin.SetSuspendedHandler(serverCtx),
|
||
|
|
},
|
||
|
|
}...,
|
||
|
|
),
|
||
|
|
rest.WithPrefix("/api/v1/admin"),
|
||
|
|
)
|
||
|
|
|
||
|
|
server.AddRoutes(
|
||
|
|
[]rest.Route{
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/login",
|
||
|
|
Handler: auth.LoginHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/logout",
|
||
|
|
Handler: auth.LogoutHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/oauth/:provider/callback",
|
||
|
|
Handler: auth.OAuthCallbackHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/oauth/:provider/start",
|
||
|
|
Handler: auth.OAuthStartHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/password/request-reset",
|
||
|
|
Handler: auth.RequestPasswordResetHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/password/reset",
|
||
|
|
Handler: auth.ResetPasswordHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/refresh",
|
||
|
|
Handler: auth.RefreshHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/register",
|
||
|
|
Handler: auth.RegisterHandler(serverCtx),
|
||
|
|
},
|
||
|
|
},
|
||
|
|
rest.WithPrefix("/api/v1/auth"),
|
||
|
|
)
|
||
|
|
|
||
|
|
server.AddRoutes(
|
||
|
|
rest.WithMiddlewares(
|
||
|
|
[]rest.Middleware{serverCtx.AuthJWT},
|
||
|
|
[]rest.Route{
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/bind",
|
||
|
|
Handler: auth.BindAccountHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/email/send-code",
|
||
|
|
Handler: auth.SendEmailCodeHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/email/verify",
|
||
|
|
Handler: auth.VerifyEmailHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodGet,
|
||
|
|
Path: "/identities",
|
||
|
|
Handler: auth.ListIdentitiesHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/logout-all",
|
||
|
|
Handler: auth.LogoutAllHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodGet,
|
||
|
|
Path: "/me",
|
||
|
|
Handler: auth.MeHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPatch,
|
||
|
|
Path: "/profile",
|
||
|
|
Handler: auth.UpdateProfileHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPut,
|
||
|
|
Path: "/profile",
|
||
|
|
Handler: auth.UpdateProfilePutHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/unbind",
|
||
|
|
Handler: auth.UnbindAccountHandler(serverCtx),
|
||
|
|
},
|
||
|
|
}...,
|
||
|
|
),
|
||
|
|
rest.WithPrefix("/api/v1/auth"),
|
||
|
|
)
|
||
|
|
|
||
|
|
server.AddRoutes(
|
||
|
|
rest.WithMiddlewares(
|
||
|
|
[]rest.Middleware{serverCtx.AuthJWT},
|
||
|
|
[]rest.Route{
|
||
|
|
{
|
||
|
|
Method: http.MethodPost,
|
||
|
|
Path: "/upload",
|
||
|
|
Handler: media.UploadHandler(serverCtx),
|
||
|
|
},
|
||
|
|
}...,
|
||
|
|
),
|
||
|
|
rest.WithPrefix("/api/v1/media"),
|
||
|
|
)
|
||
|
|
|
||
|
|
server.AddRoutes(
|
||
|
|
[]rest.Route{
|
||
|
|
{
|
||
|
|
Method: http.MethodGet,
|
||
|
|
Path: "/health",
|
||
|
|
Handler: ping.HealthHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodGet,
|
||
|
|
Path: "/ping",
|
||
|
|
Handler: ping.PingHandler(serverCtx),
|
||
|
|
},
|
||
|
|
},
|
||
|
|
rest.WithPrefix("/api/v1"),
|
||
|
|
)
|
||
|
|
|
||
|
|
server.AddRoutes(
|
||
|
|
rest.WithMiddlewares(
|
||
|
|
[]rest.Middleware{serverCtx.AuthJWT},
|
||
|
|
[]rest.Route{
|
||
|
|
{
|
||
|
|
Method: http.MethodGet,
|
||
|
|
Path: "/ai",
|
||
|
|
Handler: settings.GetAiHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPut,
|
||
|
|
Path: "/ai",
|
||
|
|
Handler: settings.SaveAiHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodGet,
|
||
|
|
Path: "/models",
|
||
|
|
Handler: settings.ListModelsHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodGet,
|
||
|
|
Path: "/placement",
|
||
|
|
Handler: settings.GetPlacementHandler(serverCtx),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
Method: http.MethodPut,
|
||
|
|
Path: "/placement",
|
||
|
|
Handler: settings.SavePlacementHandler(serverCtx),
|
||
|
|
},
|
||
|
|
}...,
|
||
|
|
),
|
||
|
|
rest.WithPrefix("/api/v1/settings"),
|
||
|
|
)
|
||
|
|
}
|