61 lines
1.7 KiB
Go
61 lines
1.7 KiB
Go
// Code generated by atomctl. DO NOT EDIT.
|
|
|
|
// Package v1 provides HTTP route definitions and registration
|
|
// for the quyun/v2 application.
|
|
package v1
|
|
|
|
import (
|
|
"mime/multipart"
|
|
"quyun/v2/app/middlewares"
|
|
"quyun/v2/app/requests"
|
|
"quyun/v2/providers/jwt"
|
|
|
|
"github.com/gofiber/fiber/v3"
|
|
log "github.com/sirupsen/logrus"
|
|
_ "go.ipao.vip/atom"
|
|
_ "go.ipao.vip/atom/contracts"
|
|
. "go.ipao.vip/atom/fen"
|
|
)
|
|
|
|
// Routes implements the HttpRoute contract and provides route registration
|
|
// for all controllers in the v1 module.
|
|
//
|
|
// @provider contracts.HttpRoute atom.GroupRoutes
|
|
type Routes struct {
|
|
log *log.Entry `inject:"false"`
|
|
middlewares *middlewares.Middlewares
|
|
// Controller instances
|
|
demo *demo
|
|
}
|
|
|
|
// Prepare initializes the routes provider with logging configuration.
|
|
func (r *Routes) Prepare() error {
|
|
r.log = log.WithField("module", "routes.v1")
|
|
r.log.Info("Initializing routes module")
|
|
return nil
|
|
}
|
|
|
|
// Name returns the unique identifier for this routes provider.
|
|
func (r *Routes) Name() string {
|
|
return "v1"
|
|
}
|
|
|
|
// Register registers all HTTP routes with the provided fiber router.
|
|
// Each route is registered with its corresponding controller action and parameter bindings.
|
|
func (r *Routes) Register(router fiber.Router) {
|
|
// Register routes for controller: demo
|
|
r.log.Debugf("Registering route: Post /v1/medias/:id -> demo.Foo")
|
|
router.Post("/v1/medias/:id"[len(r.Path()):], Func7(
|
|
r.demo.Foo,
|
|
PathParam[int]("id"),
|
|
Query[requests.Pagination]("pager"),
|
|
Query[FooQuery]("query"),
|
|
Header[FooHeader]("header"),
|
|
Local[*jwt.Claims]("claim"),
|
|
File[multipart.FileHeader]("file"),
|
|
Body[FooUploadReq]("req"),
|
|
))
|
|
|
|
r.log.Info("Successfully registered all routes")
|
|
}
|