mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-06 01:06:22 +00:00
⚡ add middleware for authentication and captcha, implement initial API routes for user, post, label, and page
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user