Example #1
0
func main() {
	p := pager.NewUrlPager(10, 1, nil)
	fmt.Println(p.PagerString())
	fmt.Println("--------------------------")

	p = pager.NewUrlPager(0, 0, nil)
	fmt.Println(p.PagerString())
	fmt.Println("--------------------------")
	p = pager.NewUrlPager(10, 10, nil)
	fmt.Println(p.PagerString())

	fmt.Println("--------------------------")
	p = pager.NewUrlPager(10, 9, nil)
	fmt.Println(p.PagerString())

	return

	context := glob.NewContext()
	goclient.Configure("tcp", ":"+context.Config().GetString(variable.SocketPort), context)
	context.DebugMode = true
	jsv.Configure(context)

	//fmt.Println(ording.NewSecret(101))

	go testRegister()
	go testPartner()
	go testSubmitOrder()

	testMemberLogin()
	for {
		time.Sleep(10 * time.Second)
		go testMemberLogin()
	}
}
Example #2
0
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)
	}
}
Example #3
0
// 运行网页
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)
	}
}