-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (45 loc) · 1.51 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"net/url"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
"github.com/astaxie/beego/plugins/cors"
_ "github.com/lib/pq"
_ "github.com/udistrital/giros_crud/routers"
apistatus "github.com/udistrital/utils_oas/apiStatusLib"
"github.com/udistrital/utils_oas/auditoria"
"github.com/udistrital/utils_oas/customerror"
"github.com/udistrital/utils_oas/xray"
)
func main() {
orm.Debug = true
//orm.RegisterDataBase("default", "postgres", beego.AppConfig.String("sqlconn"))
orm.RegisterDataBase("default", "postgres", "postgres://"+
beego.AppConfig.String("PGuser")+":"+
url.QueryEscape(beego.AppConfig.String("PGpass"))+"@"+
beego.AppConfig.String("PGhost")+":"+
beego.AppConfig.String("PGport")+"/"+
beego.AppConfig.String("PGdb")+"?sslmode=disable&search_path="+
beego.AppConfig.String("PGschema")+"")
if beego.BConfig.RunMode == "dev" {
beego.BConfig.WebConfig.DirectoryIndex = true
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
}
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowOrigins: []string{"*"},
AllowMethods: []string{"PUT", "PATCH", "GET", "POST", "OPTIONS", "DELETE"},
AllowHeaders: []string{"Origin", "x-requested-with",
"content-type",
"accept",
"origin",
"authorization",
"x-csrftoken"},
ExposeHeaders: []string{"Content-Length"},
AllowCredentials: true,
}))
auditoria.InitMiddleware()
beego.ErrorController(&customerror.CustomErrorController{})
xray.InitXRay()
apistatus.Init()
beego.Run()
}