本文整理汇总了Golang中github.com/jsix/gof.App类的典型用法代码示例。如果您正苦于以下问题:Golang App类的具体用法?Golang App怎么用?Golang App使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了App类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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)) //启动服务
}
开发者ID:yonglehou,项目名称:go2o,代码行数:7,代码来源:serve.go
示例2: handleCustomError
// 处理自定义错误
func handleCustomError(w http.ResponseWriter, ctx gof.App, err error) {
if err != nil {
ctx.Template().Execute(w, gof.TemplateDataMap{
"error": err.Error(),
"statck": template.HTML(strings.Replace(string(debug.Stack()), "\n", "<br />", -1)),
},
"views/shop/ols/{device}/error.html")
}
}
开发者ID:zoe527,项目名称:go2o,代码行数:10,代码来源:util.go
示例3: 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)
}
}
开发者ID:tonycoming,项目名称:go2o,代码行数:25,代码来源:rest_server.go
示例4: 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)
}
}
开发者ID:zoe527,项目名称:go2o,代码行数:24,代码来源:web_server.go
示例5: NewMerchantQuery
func NewMerchantQuery(c gof.App) *MerchantQuery {
return &MerchantQuery{
Connector: c.Db(),
Storage: c.Storage(),
}
}
开发者ID:yonglehou,项目名称:go2o,代码行数:6,代码来源:merchant_query.go
示例6: Configure
func Configure(c gof.App) {
Context = c
debugMode = c.Debug()
}
开发者ID:marknewmail,项目名称:gof,代码行数:4,代码来源:jsv.go
示例7: NewShopQuery
func NewShopQuery(c gof.App) *ShopQuery {
return &ShopQuery{
Connector: c.Db(),
Storage: c.Storage(),
}
}
开发者ID:yonglehou,项目名称:go2o,代码行数:6,代码来源:shop_query.go
示例8: NewPartnerQuery
func NewPartnerQuery(c gof.App) *PartnerQuery {
return &PartnerQuery{
Connector: c.Db(),
Storage: c.Storage(),
}
}
开发者ID:zoe527,项目名称:go2o,代码行数:6,代码来源:partner_query.go
示例9: setupOrder
func (this *Shopping) setupOrder(ctx gof.App, v *shopping.ValueOrder,
conf *partner.SaleConf, t time.Time, f func(error)) {
var err error
order := this.CreateOrder(v, nil)
dur := time.Duration(t.Unix()-v.CreateTime) * time.Second
if v.PaymentOpt == enum.PAY_ONLINE {
if v.IsPaid == 0 && dur > time.Hour*order_timeout_hour {
order.Cancel("超时未付款,系统取消")
if ctx.Debug() {
ctx.Log().Printf("[ AUTO][OrderSetup]:%s - Payment Timeout\n", v.OrderNo)
}
}
} else if v.PaymentOpt == enum.PAY_OFFLINE {
switch v.Status + 1 {
case enum.ORDER_WAIT_CONFIRM:
if dur > time.Minute*order_confirm_minute {
err = order.Confirm()
if ctx.Debug() {
ctx.Log().Printf("[ AUTO][OrderSetup]:%s - Confirm \n", v.OrderNo)
}
shop, err := this.SmartChoiceShop(v.DeliverAddress)
if err != nil {
log.Println(err)
order.Suspend("智能分配门店失败!原因:" + err.Error())
} else {
sv := shop.GetValue()
order.SetShop(shop.GetDomainId())
order.AppendLog(enum.ORDER_LOG_SETUP, false, fmt.Sprintf(
"自动分配门店:%s,电话:%s", sv.Name, sv.Phone))
}
}
case enum.ORDER_WAIT_DELIVERY:
if dur > time.Minute*order_process_minute {
err = order.Process()
if ctx.Debug() {
ctx.Log().Printf("[ AUTO][OrderSetup]:%s - Processing \n", v.OrderNo)
}
}
case enum.ORDER_WAIT_RECEIVE:
if dur > time.Minute*order_sending_minute {
err = order.Deliver()
if ctx.Debug() {
ctx.Log().Printf("[ AUTO][OrderSetup]:%s - Sending \n", v.OrderNo)
}
}
case enum.ORDER_RECEIVED:
if dur > time.Hour*order_receive_hour {
err = order.SignReceived()
if ctx.Debug() {
ctx.Log().Printf("[ AUTO][OrderSetup]:%s - Received \n", v.OrderNo)
}
}
case enum.ORDER_COMPLETED:
if dur > time.Hour*order_complete_hour {
err = order.Complete()
if ctx.Debug() {
ctx.Log().Printf("[ AUTO][OrderSetup]:%s - Complete \n", v.OrderNo)
}
}
}
}
if err != nil {
f(err)
}
}
开发者ID:jackyan,项目名称:go2o,代码行数:69,代码来源:shopping.go
注:本文中的github.com/jsix/gof.App类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论