43 lines
924 B
Go
43 lines
924 B
Go
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"
|
|
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(fiber.Config{
|
|
BodyLimit: 5 * 1024 * 1024,
|
|
StructValidator: &structValidator{validate: validator.New()},
|
|
})
|
|
app.Use(trace.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))
|
|
|
|
{
|
|
api := app.Group("/api/v1/auth")
|
|
api.Post("/login", handler.Login())
|
|
}
|
|
|
|
return app
|
|
}
|