26 lines
567 B
Go
26 lines
567 B
Go
package main
|
|
|
|
import (
|
|
"server/models"
|
|
_ "server/models" // 确保菜单模型被正确导入
|
|
_ "server/routers"
|
|
|
|
beego "github.com/beego/beego/v2/server/web"
|
|
"github.com/beego/beego/v2/server/web/context"
|
|
)
|
|
|
|
func main() {
|
|
// 初始化数据库
|
|
models.Init()
|
|
|
|
// CORS配置已移至router.go中统一管理
|
|
// 确保请求体被正确读取
|
|
beego.InsertFilter("*", beego.BeforeRouter, func(ctx *context.Context) {
|
|
if ctx.Input.Method() == "PUT" || ctx.Input.Method() == "POST" {
|
|
ctx.Input.CopyBody(1024 * 1024) // 1MB 缓冲区
|
|
}
|
|
})
|
|
|
|
beego.Run()
|
|
}
|