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


Golang routing.HTTPSession类代码示例

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


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

示例1: AddA

func AddA(hs *routing.HTTPSession) routing.HResult {
	var key string
	var val string
	err := hs.ValidCheckVal(`
		key,R|S,L:0;
		val,R|S,L:0;
		`, &key, &val)
	if err != nil {
		hs.W.Write([]byte(`
			{
				"code":1,
				"msg":"error"
			}
			`))
		return routing.HRES_RETURN
	}
	Vars[key] = val
	hs.W.Write([]byte(`
			{
				"code":0,
				"data":""
			}
			`))
	return routing.HRES_RETURN
}
开发者ID:Centny,项目名称:igtest_ex,代码行数:25,代码来源:pkga.go

示例2: GetB

func GetB(hs *routing.HTTPSession) routing.HResult {
	var key string
	err := hs.ValidCheckVal(`
		key,R|S,L:0;
		`, &key)
	if err != nil {
		hs.W.Write([]byte(`
			{
				"code":1,
				"msg":"error"
			}
			`))
		return routing.HRES_RETURN
	}
	if v, ok := Vars[key]; ok {
		hs.W.Write([]byte(fmt.Sprintf(`
			{
				"code":0,
				"data":"%v"
			}
			`, v)))
	} else {
		hs.W.Write([]byte(`
			{
				"code":1,
				"msg":"key not found"
			}
			`))
	}
	return routing.HRES_RETURN
}
开发者ID:Centny,项目名称:igtest_ex,代码行数:31,代码来源:pkgb.go

示例3: DelA

func DelA(hs *routing.HTTPSession) routing.HResult {
	var key string
	err := hs.ValidCheckVal(`
		key,R|S,L:0;
		`, &key)
	if err != nil {
		hs.W.Write([]byte(`
			{
				"code":1,
				"msg":"error"
			}
			`))
		return routing.HRES_RETURN
	}
	if _, ok := Vars[key]; ok {
		delete(Vars, key)
		hs.W.Write([]byte(`
			{
				"code":0,
				"data":""
			}
			`))
	} else {
		hs.W.Write([]byte(`
			{
				"code":1,
				"msg":"key not found"
			}
			`))
	}
	return routing.HRES_RETURN
}
开发者ID:Centny,项目名称:igtest_ex,代码行数:32,代码来源:pkga.go

示例4: AddB

func AddB(hs *routing.HTTPSession) routing.HResult {
	var key string
	var val string
	err := hs.ValidCheckVal(`
		key,R|S,L:0;
		val,R|S,L:0;
		`, &key, &val)
	if err != nil {
		hs.W.Write([]byte(`
			{
				"code":1,
				"msg":"error"
			}
			`))
		return routing.HRES_RETURN
	}
	if _, ok := pkga.Vars[key]; ok {
		Vars[key] = val
		hs.W.Write([]byte(`
			{
				"code":0,
				"data":""
			}
			`))
	} else {
		hs.W.Write([]byte(`
			{
				"code":1,
				"msg":"key not found"
			}
			`))
	}
	return routing.HRES_RETURN
}
开发者ID:Centny,项目名称:igtest_ex,代码行数:34,代码来源:pkgb.go

示例5: SrvHTTP

func (t *T2) SrvHTTP(hs *routing.HTTPSession) routing.HResult {
	fmt.Println(hs.CheckVal("a"))
	fmt.Println(hs.CheckVal("b"))
	fmt.Println(c)
	c = c + 1
	hs.W.Write([]byte("{\"OK\":1}"))
	return routing.HRES_RETURN
}
开发者ID:Centny,项目名称:Cny4go,代码行数:8,代码来源:httptest_test.go

示例6: JcrStore

func JcrStore(hs *routing.HTTPSession) routing.HResult {
	var cover string
	err := hs.ValidRVal(`
		cover,R|S,L:0
		`, &cover)
	if err != nil {
		return hs.MsgResE(1, err.Error())
	}
	spath := _conf_.SavePath()
	log.D("saving coverage report to %s", spath)
	err = util.FWrite(spath, cover)
	if err != nil {
		log.E("saving coverage report to %s error:%s", spath, err.Error())
		return hs.MsgResE(1, err.Error())
	} else {
		return hs.MsgRes("SUCCESS")
	}
}
开发者ID:Centny,项目名称:Cny4go,代码行数:18,代码来源:jcr.go

示例7: JcrExit

func JcrExit(hs *routing.HTTPSession) routing.HResult {
	log.D("Jcr receiving exit command...")
	StopSrv()
	return hs.MsgRes("SUCCESS")
}
开发者ID:Centny,项目名称:Cny4go,代码行数:5,代码来源:jcr.go

示例8: JcrJs

func JcrJs(hs *routing.HTTPSession) routing.HResult {
	hs.SendT(fmt.Sprintf("var jcr_store='http://%s%s/store';%s",
		hs.R.Host, filepath.Dir(hs.R.RequestURI), _jcr_js_),
		"text/javascript;charset=utf-8")
	return routing.HRES_RETURN
}
开发者ID:Centny,项目名称:Cny4go,代码行数:6,代码来源:jcr.go

示例9: JcrConf

func JcrConf(hs *routing.HTTPSession) routing.HResult {
	hs.JsonRes(_conf_)
	return routing.HRES_RETURN
}
开发者ID:Centny,项目名称:Cny4go,代码行数:4,代码来源:jcr.go

示例10: SrvHTTP

func (f *Favicon) SrvHTTP(hs *routing.HTTPSession) routing.HResult {
	fmt.Println(hs, f)
	hs.SendF("favicon.ico", f.Path, "image/x-icon", false)
	return routing.HRES_RETURN
}
开发者ID:Centny,项目名称:Cny4go,代码行数:5,代码来源:favicon.go


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