码农笔录博客源码
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

37 wiersze
1.1 KiB

6 lat temu
package main
import (
"beeblog/filter"
"beeblog/models"
6 lat temu
_ "beeblog/routers"
4 lat temu
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
beego "github.com/beego/beego/v2/server/web"
"github.com/beego/beego/v2/server/web/filter/cors"
6 lat temu
)
func init() {
models.RegistDB()
beego.InsertFilter("/*", beego.BeforeRouter, filter.LogFilter)
beego.InsertFilter("/api/*", beego.BeforeRouter, filter.FilterAdmin)
6 lat temu
}
func main() {
6 lat temu
orm.Debug = false
4 lat temu
beego.AddFuncMap("NAdd", NAdd)
6 lat temu
logs.SetLogger(logs.AdapterFile, `{"filename":"/opt/logs/aiprose.log","level":1}`)
6 lat temu
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowAllOrigins: true,
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowHeaders: []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
AllowCredentials: true,
}))
6 lat temu
beego.Run()
}
4 lat temu
func NAdd(n1 int, n2 int) int {
return n1 + n2
}