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

37 rindas
1.1 KiB

pirms 6 gadiem
package main
import (
"beeblog/filter"
"beeblog/models"
pirms 6 gadiem
_ "beeblog/routers"
pirms 4 gadiem
"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"
pirms 6 gadiem
)
func init() {
models.RegistDB()
pirms 6 gadiem
beego.InsertFilter("/*", beego.BeforeRouter, filter.LogFilter)
beego.InsertFilter("/api/*", beego.BeforeRouter, filter.FilterAdmin)
pirms 6 gadiem
}
func main() {
pirms 6 gadiem
orm.Debug = false
pirms 4 gadiem
beego.AddFuncMap("NAdd", NAdd)
pirms 6 gadiem
logs.SetLogger(logs.AdapterFile, `{"filename":"/opt/logs/aiprose.log","level":1}`)
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 4 gadiem
func NAdd(n1 int, n2 int) int {
pirms 6 gadiem
return n1 + n2
}