yunzer_go/server/main.go
2025-11-13 11:28:00 +08:00

30 lines
738 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"server/models"
_ "server/routers"
"server/version"
beego "github.com/beego/beego/v2/server/web"
"github.com/beego/beego/v2/server/web/context"
)
func main() {
// 初始化数据库
models.Init(version.Version)
// CORS配置已移至router.go中统一管理
// 确保请求体被正确读取(包括 POST、PUT、PATCH
beego.InsertFilter("*", beego.BeforeRouter, func(ctx *context.Context) {
method := ctx.Input.Method()
if method == "PUT" || method == "POST" || method == "PATCH" {
ctx.Input.CopyBody(1024 * 1024) // 1MB 缓冲区
}
})
// 静态资源:映射 /uploads 到本地 uploads 目录,供前端访问上传文件
beego.SetStaticPath("/uploads", "uploads")
beego.Run()
}