cedar-router的一个sessio组件。
2个方法Set(strig,iterface{})Get(strig)iterface{}使用方法r:=cedar.NewRouter()
x:=cedar_sessio.NewSessio(r)
x继承所有的httpmethod和group ,只是有些小改动,不能直接使用,只能在httpmethod中使用
从之前的
r.Get("/",fuc(whttp.ResposeWriter,r*http.Request,il)r.Group("/a",fuc(groups*cedar.Groups){}到现在的
x.Get("/",fuc(whttp.ResposeWriter,r*http.Request,scedar_sessio.Sessio),il)x.Group("/a",fuc(groups*cedar_sessio.TheGroup){}改了参数,更多 例子 ,现在使用的是系统自带的map,可能以后会换成 spruce ,分布式的kv数据库
例子
r:=cedar.NewRouter()x:=cedar_sessio.NewSessio(r)x.Get("/set",fuc(whttp.ResposeWriter,r*http.Request,scedar_sessio.Sessio){s.Set("hello","world"+r.RemoteAddr)//设置sessios.Get("hello")//获取sessiow.Write([]byte("hellosessio"))},il)
评论