cedar-session cedar-router 的 session 组件开源项目

我要开发同款
匿名用户2020年03月12日
94阅读
开发技术GO语言
所属分类Google Go、路由器/防火墙、服务器软件
授权协议GPL

作品详情

cedar-router的一个session组件。

2个方法Set(string,interface{})Get(string)interface{}使用方法

r:=cedar.NewRouter()

x:=cedar_session.NewSession(r)

x继承所有的httpmethod和group ,只是有些小改动,不能直接使用,只能在httpmethod中使用

从之前的 

r.Get("/",func(whttp.ResponseWriter,r*http.Request,nil)r.Group("/a",func(groups*cedar.Groups){}

到现在的

x.Get("/",func(whttp.ResponseWriter,r*http.Request,scedar_session.Session),nil)x.Group("/a",func(groups*cedar_session.TheGroup){}

改了参数,更多 例子 ,现在使用的是系统自带的map,可能以后会换成 spruce ,分布式的kv数据库

例子

r:=cedar.NewRouter()x:=cedar_session.NewSession(r)x.Get("/set",func(whttp.ResponseWriter,r*http.Request,scedar_session.Session){s.Set("hello","world"+r.RemoteAddr)//设置sessions.Get("hello")//获取sessionw.Write([]byte("hellosession"))},nil)

 

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论