-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.go
31 lines (29 loc) · 852 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/orm"
"github.com/khlipeng/beego_api/controllers"
"github.com/khlipeng/beego_api/models"
_ "github.com/khlipeng/beego_api/routers"
"time"
)
func init() {
models.Init()
corsHandler := func(ctx *context.Context) {
ctx.Output.Header("Access-Control-Allow-Origin", ctx.Input.Domain())
ctx.Output.Header("Access-Control-Allow-Methods", "*")
}
beego.InsertFilter("*", beego.BeforeRouter, corsHandler)
}
func main() {
if beego.BConfig.RunMode == "dev" {
beego.BConfig.WebConfig.DirectoryIndex = true
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
orm.Debug = true
}
orm.DefaultTimeLoc = time.UTC
beego.ErrorController(&controllers.ErrorController{})
beego.BConfig.ServerName = "snail server 1.0"
beego.Run()
}