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


Golang kmgHttp.Context类代码示例

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


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

示例1: CreateFromSelectCommandAndHttpContext

func CreateFromSelectCommandAndHttpContext(Select *MysqlAst.SelectCommand, Ctx *kmgHttp.Context) *KmgPage {
	page := &KmgPage{}
	page.BaseUrl = Ctx.GetRequestUrl()
	page.CurrentPage = Ctx.InNum("Page")
	page.PageKeyName = "Page"
	page.init()
	return page.runSelectCommand(Select)
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:8,代码来源:kmgPage.go

示例2: RequestLogger

// 默认不用这个,容易搞的测试里面到处都是log.
// TODO 静态文件的log问题
// TODO 尝试搞出更好用的log系统.
func RequestLogger(ctx *kmgHttp.Context, processorList []HttpProcessor) {
	startTime := time.Now()
	processorList[0](ctx, processorList[1:])
	time := time.Since(startTime)
	log := ctx.Log()
	log.ProcessTime = kmgTime.DurationFormat(time)
	kmgLog.Log("Request", log)
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:11,代码来源:runner.go

示例3: PanicHandler

func PanicHandler(ctx *kmgHttp.Context, processorList []HttpProcessor) {
	err := kmgErr.PanicToErrorAndLog(func() {
		processorList[0](ctx, processorList[1:])
	})
	if err != nil {
		ctx.Error(err)
		return
	}
	return
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:10,代码来源:runner.go

示例4: DemoPostAction

func (e Example) DemoPostAction(ctx *kmgHttp.Context) {
	ctx.MustPost()
	b := kmgYaml.MustMarshal(ctx.GetInMap())
	ctx.WriteString(kmgBootstrap.NewWrap("DemoPostAction", kmgBootstrap.Pre(`
You send me a HTTP POST Request
`+string(b))).HtmlRender())
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:7,代码来源:kmgBootstrapExample.go

示例5: Dispatcher

func Dispatcher(ctx *kmgHttp.Context, processorList []HttpProcessor) {
	apiName := ctx.InStr("n")
	if apiName == "" && EnterPointApiName != "" {
		if ctx.GetRequestUrl() == "/favicon.ico" {
			// 避免网站图标请求,占用大量资源.
			ctx.NotFound("api not found")
			return
		}
		apiName = EnterPointApiName
	}
	apiFunc, ok := controllerObjMap[apiName]
	if !ok {
		ctx.NotFound("api not found")
		return
	}

	apiFunc(ctx)
	return
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:19,代码来源:runner.go

示例6: Demo1

func (e Example) Demo1(ctx *kmgHttp.Context) {
	ctx.WriteString(kmgBootstrap.NewWrap("kmg bootstrap demo",
		kmgBootstrap.NavBar{
			Title: kmgView.String("kmgBootstrap DEMO"),
			OptionList: []kmgBootstrap.NavBarNode{
				{Name: "主页", Url: "/"},
				{
					Name: "测试菜单1",
					Url:  "/?menu=1",
					ChildList: []kmgBootstrap.NavBarNode{
						{
							Name: "测试菜单-子菜单1-1",
							Url:  "/?menu=1-1",
							ChildList: []kmgBootstrap.NavBarNode{
								{
									Name: "测试菜单-子菜单1-1-1",
									Url:  "/?menu=1-1-1",
									ChildList: []kmgBootstrap.NavBarNode{
										{Name: "测试菜单-子菜单1-1-1-1", Url: "/?menu=1-1-1-1"},
									},
								},
								{Name: "测试菜单-子菜单1-1-2", Url: "/?menu=1-1-2"},
							},
						},
						{Name: "测试菜单-子菜单1-2", Url: "/?menu=1-2"},
					},
				},
			},
			RightOptionList: []kmgBootstrap.NavBarNode{
				{
					Name: "测试菜单1右",
					Url:  "/",
					ChildList: []kmgBootstrap.NavBarNode{
						{Name: "测试菜单-子菜单1-1右边", Url: "/"},
					},
				},
			},
		},
		kmgBootstrap.Panel{
			Title: "Panel",
			Body: kmgBootstrap.Panel{
				Title: "Panel",
				Body:  kmgView.String("Body"),
			},
		},
		kmgBootstrap.Panel{
			Title: "Table",
			Body: kmgBootstrap.Table{
				Caption: kmgView.String("Caption"),
				TitleList: []kmgView.HtmlRenderer{
					kmgView.String("title1"),
					kmgView.String("title2"),
				},
				DataList: [][]kmgView.HtmlRenderer{
					{
						kmgView.String("r1c1"),
						kmgView.String("r1c2"),
					},
					{
						kmgView.String("r2c1"),
						kmgView.String("r2c2"),
					},
				},
			},
		},
		kmgBootstrap.Panel{
			Title: "DropDown",
			Body: kmgView.HtmlRendererList{
				kmgView.String("使用 DropDown"),
				kmgBootstrap.DropDown{
					Title: kmgBootstrap.Button{
						Size:  kmgBootstrap.ButtonSizeSmall,
						Color: kmgBootstrap.ButtonColorSuccess,
						Content: kmgView.HtmlRendererList{
							kmgView.String("更多"),
							kmgBootstrap.Blank(1),
							kmgBootstrap.NewCaret(),
						},
					},
					OptionList: []kmgBootstrap.NavBarNode{
						{
							Name: "Say",
							Url:  "/",
							ChildList: []kmgBootstrap.NavBarNode{
								{
									Name: "你好",
								},
								{
									Name: "Hello",
								},
								{
									Name: "もしもし",
								},
								{
									Name: "Ciao",
								},
							},
						},
						{
							Name: "Do",
//.........这里部分代码省略.........
开发者ID:keysonZZZ,项目名称:kmg,代码行数:101,代码来源:kmgBootstrapExample.go

示例7: Count

func (t TestApiObj) Count(ctx *kmgHttp.Context) {
	shareSessionId = ctx.Session.Id
	ctx.WriteString(ctx.Session.Id)
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:4,代码来源:Session_test.go

示例8: TestHandleUploadFile

func (t TestObj) TestHandleUploadFile(ctx *kmgHttp.Context) {
	fileInfo := ctx.MustInFile("UFile")
	file, err := fileInfo.Open()
	if err != nil {
		panic(err)
	}
	defer file.Close()
	content, err := ioutil.ReadAll(file)
	if err != nil {
		panic(err)
	}
	a := ctx.InStr("a")
	ctx.WriteString(fileInfo.Filename)
	ctx.WriteString(" ")
	ctx.WriteString(a)
	ctx.WriteString(" ")
	ctx.WriteString(string(content))
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:18,代码来源:MockKmgController_test.go

示例9: TestFunc

func (t TestObj) TestFunc(ctx *kmgHttp.Context) {
	a := ctx.InNum("a")
	ctx.WriteString(strconv.Itoa(a + i))
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:4,代码来源:MockKmgController_test.go

示例10: mustNotifyActionV2

func (ot *OverseaTrade) mustNotifyActionV2(ctx *kmgHttp.Context, f func(info OverseaTradeTransaction)) {
	kmgLog.Log("Alipay", "Oversea PayNotifyAction", ctx.GetInMap())
	var err error
	ctx.MustPost()
	info := OverseaTradeTransaction{}
	//info.NotifyId = ctx.MustInStr("notify_id") 这两项没有什么意义.
	//info.NotifyTime = kmgTime.MustFromMysqlFormatInLocation(ctx.MustInStr("notify_time"), kmgTime.BeijingZone)
	info.OutTradeNo = ctx.MustInStr("out_trade_no")

	info.Currency = ctx.MustInStr("currency")
	info.TotalFee, err = kmgStrconv.ParseFloat64(ctx.MustInStr("total_fee"))
	if err != nil {
		panic(err)
	}
	info.TradeStatus = OverseaTradeStatus(ctx.MustInStr("trade_status"))
	info.TradeNo = ctx.MustInStr("trade_no")
	err = ot.md5Verify(ctx.GetInMap())
	if err != nil {
		panic(err)
	}
	err = ot.VerifyNotify(ctx.MustInStr("notify_id"))
	if err != nil {
		panic(err)
	}
	// 向支付宝询问这个订单的情况
	oInfo := ot.MustSingleTransactionQuery(info.OutTradeNo)
	if oInfo.TradeStatus != info.TradeStatus {
		panic("两次查询订单状态不一致")
	}
	info.Subject = oInfo.Subject
	f(info)
	ctx.WriteString("success")
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:33,代码来源:Oversea.go

示例11: MustReturnPage

// 同步回调
// 调用前请清除您自己的参数.
// @deprecated 请使用 OverseaTrade.PayFinishCallback 和 OverseaTrade.PayCloseCallback
func (ot *OverseaTrade) MustReturnPage(ctx *kmgHttp.Context) (info OverseaTradeTransaction) {
	kmgLog.Log("Alipay", "Oversea PayReturnPage", ctx.GetInMap())
	var err error
	info.OutTradeNo = ctx.MustInStr("out_trade_no")
	info.Currency = ctx.MustInStr("currency")
	info.TotalFee, err = kmgStrconv.ParseFloat64(ctx.MustInStr("total_fee"))
	if err != nil {
		panic(err)
	}
	info.TradeStatus = OverseaTradeStatus(ctx.MustInStr("trade_status"))
	info.TradeNo = ctx.MustInStr("trade_no")
	//这个也可以验证数据,只是文档上面没写.
	err = ot.md5Verify(ctx.GetInMap())
	if err != nil {
		panic(err)
	}
	// 向支付宝询问这个订单的情况
	oInfo := ot.MustSingleTransactionQuery(info.OutTradeNo)
	if oInfo.TradeStatus != info.TradeStatus {
		panic("两次查询订单状态不一致")
	}
	info.Subject = oInfo.Subject
	return info
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:27,代码来源:Oversea.go

示例12: NotifyAction

// 请不要手动调用,这个是自动注册到 kmgControllerRunner里面的
func (ot *OverseaTrade) NotifyAction(ctx *kmgHttp.Context) {
	ctx.DeleteInMap("n")
	ot.mustNotifyActionV2(ctx, ot.payCallbackProceess)
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:5,代码来源:Oversea.go

示例13: ReturnPage

// 请不要手动调用,这个是自动注册到 kmgControllerRunner里面的
func (ot *OverseaTrade) ReturnPage(ctx *kmgHttp.Context) {
	ctx.DeleteInMap("n")
	info := ot.MustReturnPage(ctx)
	ot.payCallbackProceess(info)
	ot.PayReturnPageCallback(info, ctx)
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:7,代码来源:Oversea.go

示例14: GetIPFromCTXAndRespond

//Server Side
func GetIPFromCTXAndRespond(ctx *kmgHttp.Context) {
	req := ctx.GetRequest()
	address := req.RemoteAddr
	address = strings.Split(address, ":")[0]
	ctx.WriteString("OK" + address)
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:7,代码来源:main.go

示例15: DemoClientIp

func (s *Demo) DemoClientIp(httpCtx *kmgHttp.Context) (ip string) {
	return httpCtx.MustGetClientIp().String()
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:3,代码来源:server.go


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