-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
32 lines (25 loc) · 985 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
32
package main
import (
"lagosapi/controllers"
_ "lagosapi/routers"
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/plugins/cors"
)
func main() {
logs.SetLogger(logs.AdapterFile, `{"filename": "./apilogs/apicalls.log", "level": 7, "maxlines": 0, "maxsize":0,"daily":true,"maxdays":10,"color":true}`)
if beego.BConfig.RunMode == "dev" {
beego.BConfig.WebConfig.DirectoryIndex = true
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
}
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowAllOrigins: false,
AllowOrigins: []string{"http://localhost:4201"},
AllowMethods: []string{"GET", "POST", "PUT", "DELETE"},
AllowHeaders: []string{"Origin", "Content-Type", "Access-control-allow-origin", "Authorization"},
ExposeHeaders: []string{"Content-Length"},
AllowCredentials: true,
}))
beego.InsertFilter("/v1/*", beego.BeforeRouter, controllers.ValidateToken)
beego.Run()
}