示例#1
0
func main() {
	// Database alias.
	name := "default"

	// Drop table and re-create.
	force := true

	// Print log.
	verbose := true

	// Error.
	err := orm.RunSyncdb(name, force, verbose)
	if err != nil {
		fmt.Println(err)
	}
	o := orm.NewOrm()
	o.Using("default")
	seed(o)

	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
		AllowAllOrigins: true,
	}))

	beego.Run()
}
示例#2
0
文件: main.go 项目: thanzen/identity
func testOnly() {
	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"},
		ExposeHeaders:   []string{"Content-Length", "Access-Control-Allow-Origin"},
	}))
}
示例#3
0
文件: main.go 项目: Uchujin/Checklist
func main() {
	//Enable Cors
	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
		AllowOrigins:     []string{"*"},
		AllowMethods:     []string{"GET", "POST"},
		AllowHeaders:     []string{"Origin"},
		ExposeHeaders:    []string{"Content-Length"},
		AllowCredentials: true,
	}))

	beego.Run()
}
示例#4
0
func main() {
	if beego.RunMode == "dev" {
		beego.DirectoryIndex = true
		beego.StaticDir["/swagger"] = "swagger"
	}
	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
		AllowOrigins:     []string{"https://*"},
		AllowMethods:     []string{"GET"},
		AllowHeaders:     []string{"Origin"},
		ExposeHeaders:    []string{"Content-Length", "Made-By"},
		AllowCredentials: true,
	}))

	beego.Run(":" + os.Getenv("PORT"))
}
示例#5
0
文件: main.go 项目: guaiguaihw/fault
func main() {

	beego.ErrorController(&controllers.FaultDataController{})

	if beego.RunMode == "dev" {
		beego.DirectoryIndex = true
		beego.StaticDir["/swagger"] = "swagger"
	}
	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
		AllowOrigins:     []string{"*"},
		AllowMethods:     []string{"PUT", "PATCH", "POST", "DELETE"},
		AllowHeaders:     []string{"accept, content-type"},
		ExposeHeaders:    []string{"Content-Length"},
		AllowCredentials: true,
	}))
	beego.Run()
}
示例#6
0
func main() {
	logmodels.InitLogger()
	logmodels.Logger.Info(logmodels.SPrintInfo("main", "** Application service start **"))

	if setCurrentArgs(os.Args) == 0 {
		models.MainInit(models.DatabaseConfig)
		beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
			AllowOrigins:     []string{"*"},
			AllowMethods:     []string{"GET", "DELETE", "PUT", "PATCH", "POST"},
			AllowHeaders:     []string{"Origin"},
			ExposeHeaders:    []string{"Content-Length"},
			AllowCredentials: true,
		}))
		beego.Run()
	} else {
		printHelp()
		logmodels.Logger.Error(logmodels.SPrintError("main", "Missing required parameters, can not start!"))
		os.Exit(0)
	}
}
示例#7
0
func main() {
	if beego.RunMode == "dev" {
		beego.DirectoryIndex = true
		beego.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,
	}))

	beego.Run()
}
示例#8
0
文件: http.go 项目: Cepave/fe
func Start() {
	if !g.Config().Http.Enabled {
		return
	}

	addr := g.Config().Http.Listen
	if addr == "" {
		return
	}

	home.ConfigRoutes()
	uic.ConfigRoutes()
	dashboard.ConfigRoutes()
	portal.ConfigRoutes()

	beego.AddFuncMap("member", uic_model.MembersByTeamId)
	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
		AllowAllOrigins: true,
	}))
	beego.Run(addr)
}
示例#9
0
文件: main.go 项目: aryaya/ifundgate
func init() {
	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
		AllowOrigins:     []string{"*"},
		AllowMethods:     []string{"GET", "PUT", "PATCH"},
		AllowHeaders:     []string{"Origin"},
		ExposeHeaders:    []string{"Content-Length"},
		AllowCredentials: true,
	}))

	beego.EnableHttpListen = false
	beego.EnableHttpTLS = true
	beego.HttpsPort = 443
	beego.HttpCertFile = "cert.pem"
	beego.HttpKeyFile = "key.pem"
	beego.SessionOn = true

	beego.SetStaticPath("/css", "static/css")
	beego.SetStaticPath("/js", "static/js")
	beego.SetStaticPath("/img", "static/img")
	beego.SetStaticPath("/fonts", "static/fonts")
	beego.SetStaticPath("/favicon.png", "./favicon.png")
}
示例#10
0
						//对 url&token=xxx&timestamp=xxx  进行签名验证,不让token在url中传输,防止token被截取

						timestampStr := fmt.Sprintf("%d", timestamp)
						signKey := ctx.Request.RequestURI + "&token=" + token.(string) + "&timestamp=" + timestampStr

						if !Verify(signKey, sign) {
							ctx.WriteString("{\"status\":0,\"message\":\"签名验证失败!\"}")
						}
					} else {
						ctx.WriteString("{sta\"status\"tus:0,\"message\":\"token 不存在!\"}")
					}
				} else {
					ctx.WriteString("{\"status\":0,\"message\":\"" + err.Error() + "\"}")
				}
			} else {
				ctx.WriteString("{\"status\":0,\"message\":\"timestamp超时!\"}")
			}
		} else {
			ctx.WriteString("{\"status\":0,\"message\":\"timestamp错误!\"}")
		}
	}
}

var AllowCors = cors.Allow(&cors.Options{
	AllowOrigins:     []string{"*"},
	AllowMethods:     []string{"GET", "DELETE", "PUT", "PATCH"},
	AllowHeaders:     []string{"Origin"},
	ExposeHeaders:    []string{"Content-Length"},
	AllowCredentials: true,
})