wip: 登录和认证
This commit is contained in:
@ -2,20 +2,33 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"loveuer/utodo/internal/handler"
|
||||
"loveuer/utodo/internal/opt"
|
||||
g_handler "loveuer/utodo/pkg/handler"
|
||||
"loveuer/utodo/pkg/middleware/logger"
|
||||
"loveuer/utodo/pkg/middleware/trace"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
l3 "github.com/gofiber/fiber/v3/middleware/logger"
|
||||
r3 "github.com/gofiber/fiber/v3/middleware/recover"
|
||||
)
|
||||
|
||||
type structValidator struct {
|
||||
validate *validator.Validate
|
||||
}
|
||||
|
||||
func (v *structValidator) Validate(out any) error {
|
||||
return v.validate.Struct(out)
|
||||
}
|
||||
|
||||
func New(ctx context.Context) *fiber.App {
|
||||
app := fiber.New()
|
||||
app := fiber.New(fiber.Config{
|
||||
BodyLimit: 5 * 1024 * 1024,
|
||||
StructValidator: &structValidator{validate: validator.New()},
|
||||
})
|
||||
app.Use(trace.New())
|
||||
app.Use(l3.New())
|
||||
// app.Use(l3.New())
|
||||
app.Use(logger.New())
|
||||
app.Use(r3.New())
|
||||
|
||||
app.Get("/healthz", g_handler.Healthz(opt.Cfg.Name, opt.Cfg.Version))
|
||||
|
Reference in New Issue
Block a user