add middleware for authentication and captcha, implement initial API routes for user, post, label, and page

This commit is contained in:
2025-07-18 03:26:15 +08:00
parent 70b653a88b
commit 99a3f80e12
40 changed files with 4545 additions and 21 deletions

View File

@ -1,15 +1,32 @@
package router
import (
"errors"
"github.com/cloudwego/hertz/pkg/app/server"
v1 "github.com/snowykami/neo-blog/internal/router/v1"
"github.com/snowykami/neo-blog/internal/router/apiv1"
"github.com/snowykami/neo-blog/pkg/constant"
"github.com/snowykami/neo-blog/pkg/utils"
)
var h *server.Hertz
func Run() error {
mode := utils.Getenv("MODE", constant.ModeProd) // dev | prod
switch mode {
case constant.ModeProd:
h.Spin()
return nil
case constant.ModeDev:
return h.Run()
default:
return errors.New("unknown mode: " + mode)
}
}
func init() {
h := server.New(
h = server.New(
server.WithHostPorts(":"+utils.Getenv("PORT", "8888")),
server.WithMaxRequestBodySize(utils.GetenvAsInt("MAX_REQUEST_BODY_SIZE", 1048576000)), // 1000MiB
)
v1.RegisterRoutes()
apiv1.RegisterRoutes(h)
}