码农笔录博客源码
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

36 rindas
1.1 KiB

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