码农笔录博客源码
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.

36 wiersze
1.1 KiB

6 lat temu
package main
import (
_ "beeblog/routers"
"github.com/astaxie/beego"
"beeblog/models"
"github.com/astaxie/beego/orm"
6 lat temu
"beeblog/filter"
6 lat temu
"github.com/astaxie/beego/plugins/cors"
6 lat temu
)
func init() {
models.RegistDB()
6 lat temu
beego.InsertFilter("/*", beego.BeforeRouter, filter.FilterAdmin)
6 lat temu
//beego.InsertFilter("/*", beego.FinishRouter, filter.FilterLoginInfo)
6 lat temu
}
func main() {
6 lat temu
orm.Debug = false
orm.RunSyncdb("default", false, true)
beego.AddFuncMap("NAdd",NAdd)
6 lat temu
beego.SetLevel(beego.LevelInformational)
beego.SetLogger("file", `{"filename":"/opt/logs/aiprose.log"}`)
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()
}
func NAdd(n1 int, n2 int) int{
return n1 + n2
}