本文整理汇总了Golang中github.com/jsix/gof.App.Config方法的典型用法代码示例。如果您正苦于以下问题:Golang App.Config方法的具体用法?Golang App.Config怎么用?Golang App.Config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jsix/gof.App
的用法示例。
在下文中一共展示了App.Config方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RunRestApi
func RunRestApi(app gof.App, port int) {
log.Println("[ Go2o][ API][ Booted] - Api server running on port " + strconv.Itoa(port))
//socket client
time.Sleep(time.Second * 2) //等待启动Socket
API_DOMAIN = app.Config().GetString(variable.ApiDomain)
goclient.Configure("tcp", app.Config().GetString(variable.ClientSocketServer), app)
var in *web.Interceptor = web.NewInterceptor(app, func(ctx *web.Context) {
host := ctx.Request.URL.Host
// todo: path compare
if API_HOST_CHK && host != API_DOMAIN {
http.Error(ctx.Response, "no such file", http.StatusNotFound)
return
}
api.Handle(ctx)
})
//启动服务
err := http.ListenAndServe(":"+strconv.Itoa(port), in)
if err != nil {
app.Log().Fatalln("ListenAndServer ", err)
}
}
示例2: Run
func Run(app gof.App, port int) {
sto = app.Storage()
API_DOMAIN = app.Config().GetString(variable.ApiDomain)
log.Println("** [ Go2o][ API][ Booted] - Api server running on port " +
strconv.Itoa(port))
serve.Run(":" + strconv.Itoa(port)) //启动服务
}
示例3: RunWeb
// 运行网页
func RunWeb(app gof.App, port int, debug, trace bool) {
if debug {
log.Println("** [ Go2o][ Web][ Booted] - Web server (with debug) running on port " +
strconv.Itoa(port))
infrastructure.DebugMode = true
} else {
log.Println("** [ Go2o][ Web][ Booted] - Web server running on port " + strconv.Itoa(port))
}
//socket client
time.Sleep(time.Second * 2) //等待启动Socket
API_DOMAIN = app.Config().GetString(variable.ApiDomain)
var in = getInterceptor(app)
//启动服务
err := http.ListenAndServe(":"+strconv.Itoa(port), in)
if err != nil {
app.Log().Fatalln("ListenAndServer ", err)
}
}