mirror of
https://gitee.com/johng/gf
synced 2026-06-07 10:22:11 +08:00
Merge branch 'master' into qiangg_gfsnotify
This commit is contained in:
@ -40,6 +40,7 @@ gf是开源的,免费的,基于MIT协议进行分发,开源项目地址(gi
|
||||
* [执行对象注册](http://gf.johng.cn/590882)
|
||||
* [回调方法注册](http://gf.johng.cn/590883)
|
||||
* [事件回调注册](http://gf.johng.cn/590884)
|
||||
* [服务性能分析](http://gf.johng.cn/592298)
|
||||
* [路由控制](http://gf.johng.cn/49437)
|
||||
* [Cookie](http://gf.johng.cn/494372)
|
||||
* [Session](http://gf.johng.cn/494373)
|
||||
|
||||
17
TODO
17
TODO
@ -1,12 +1,13 @@
|
||||
ON THE WAY:
|
||||
1. gdb Where方法参数的改进,研究是否可以将string参数类型修改为interface{};
|
||||
2. 增加对于数据表Model的封装;
|
||||
3. 增加fsnotify包支持;
|
||||
4. 改进gcfg和gview的文件自动更新机制;
|
||||
5. 将模板变量进行暴露,以便应用端可以进行灵活控制;
|
||||
|
||||
|
||||
DONE:
|
||||
1. gconv完善针对不同类型的判断,例如:尽量减少sprintf("%v", xxx)来执行string类型的转换;
|
||||
2. ghttp.Server请求执行中增加服务退出的方法,不再执行后续操作;
|
||||
3. ghttp.Response对象完善并改进数据返回方法(Write/WriteString);
|
||||
|
||||
ON THE WAY:
|
||||
1. gdb Where方法参数的改进,研究是否可以将string参数类型修改为interface{};
|
||||
2. 增加对于数据表Model的封装;
|
||||
3. ghttp.Server请求执行中增加服务退出的方法,不再执行后续操作;
|
||||
4. 增加fsnotify包支持;
|
||||
5. 改进gcfg和gview的文件自动更新机制;
|
||||
6. 将模板变量进行暴露,以便应用端可以进行灵活控制;
|
||||
4. ghttp.Server请求执行中增加服务退出的方法,不再执行后续操作;
|
||||
@ -29,10 +29,11 @@ type Cookie struct {
|
||||
|
||||
// cookie项
|
||||
type CookieItem struct {
|
||||
value string
|
||||
domain string // 有效域名
|
||||
path string // 有效路径
|
||||
expire int // 过期时间
|
||||
value string
|
||||
domain string // 有效域名
|
||||
path string // 有效路径
|
||||
expire int // 过期时间
|
||||
httpOnly bool
|
||||
}
|
||||
|
||||
// 获取或者创建一个cookie对象,与传入的请求对应
|
||||
@ -57,7 +58,7 @@ func (c *Cookie) init() {
|
||||
c.mu.Lock()
|
||||
for _, v := range c.request.Cookies() {
|
||||
c.data[v.Name] = CookieItem {
|
||||
v.Value, v.Domain, v.Path, v.Expires.Second(),
|
||||
v.Value, v.Domain, v.Path, v.Expires.Second(), v.HttpOnly,
|
||||
}
|
||||
}
|
||||
c.mu.Unlock()
|
||||
@ -84,12 +85,16 @@ func (c *Cookie) Set(key, value string) {
|
||||
}
|
||||
|
||||
// 设置cookie,带详细cookie参数
|
||||
func (c *Cookie) SetCookie(key, value, domain, path string, maxage int) {
|
||||
func (c *Cookie) SetCookie(key, value, domain, path string, maxAge int, httpOnly ... bool) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
c.data[key] = CookieItem {
|
||||
value, domain, path, int(gtime.Second()) + maxage,
|
||||
isHttpOnly := false
|
||||
if len(httpOnly) > 0 {
|
||||
isHttpOnly = httpOnly[0]
|
||||
}
|
||||
c.data[key] = CookieItem {
|
||||
value, domain, path, int(gtime.Second()) + maxAge, isHttpOnly,
|
||||
}
|
||||
c.mu.Unlock()
|
||||
}
|
||||
|
||||
// 查询cookie
|
||||
@ -127,11 +132,12 @@ func (c *Cookie) Output() {
|
||||
http.SetCookie(
|
||||
c.response.ResponseWriter,
|
||||
&http.Cookie {
|
||||
Name : k,
|
||||
Value : v.value,
|
||||
Domain : v.domain,
|
||||
Path : v.path,
|
||||
Expires : time.Unix(int64(v.expire), 0),
|
||||
Name : k,
|
||||
Value : v.value,
|
||||
Domain : v.domain,
|
||||
Path : v.path,
|
||||
Expires : time.Unix(int64(v.expire), 0),
|
||||
HttpOnly : v.httpOnly,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user