当前位置: 首页>>代码示例>>Golang>>正文


Golang gof.App类代码示例

本文整理汇总了Golang中github.com/atnet/gof.App的典型用法代码示例。如果您正苦于以下问题:Golang App类的具体用法?Golang App怎么用?Golang App使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了App类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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:xianmau,项目名称:go2o,代码行数:10,代码来源:util.go

示例2: RunRestApi

func RunRestApi(app gof.App, port int) {
	fmt.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:henrylee2cn,项目名称:go2o,代码行数:25,代码来源:rest_server.go

示例3: RunWeb

// 运行网页
func RunWeb(app gof.App, port int, debug, trace bool) {

	if debug {
		fmt.Println("[Started]:Web server (with debug) running on port [" +
			strconv.Itoa(port) + "]:")
		infrastructure.DebugMode = true
	} else {
		fmt.Println("[Started]:Web 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 = getInterceptor(app)

	//注册路由
	RegisterRoutes(app)

	//启动服务
	err := http.ListenAndServe(":"+strconv.Itoa(port), in)

	if err != nil {
		app.Log().Fatalln("ListenAndServer ", err)
	}
}
开发者ID:honj51,项目名称:go2o,代码行数:28,代码来源:web_server.go

示例4: RunWeb

// 运行网页
func RunWeb(app gof.App, port int, debug, trace bool) {

	if debug {
		fmt.Println("[ Go2o][ Web][ Booted] - Web server (with debug) running on port " +
			strconv.Itoa(port))
		infrastructure.DebugMode = true
	} else {
		fmt.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:henrylee2cn,项目名称:go2o,代码行数:24,代码来源:web_server.go

示例5: 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_CONFIRMED:
			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_PROCESSING:
			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_SENDING:
			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:heofonum,项目名称:go2o,代码行数:69,代码来源:shopping.go

示例6: NewPartnerQuery

func NewPartnerQuery(c gof.App) *PartnerQuery {
	return &PartnerQuery{
		Connector: c.Db(),
		Storage:   c.Storage(),
	}
}
开发者ID:xianmau,项目名称:go2o,代码行数:6,代码来源:partner_query.go


注:本文中的github.com/atnet/gof.App类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。