From c229573778788c83a2e559a5df03d0872aaebd12 Mon Sep 17 00:00:00 2001 From: john Date: Thu, 1 Nov 2018 09:46:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E3=80=81=E6=A8=A1=E6=9D=BF=E5=BC=95=E6=93=8E=E3=80=81?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E6=A8=A1=E5=BC=8F=E7=9A=84=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E5=90=8D=E7=A7=B0=E4=B8=BA=E5=A4=A7=E5=86=99?= =?UTF-8?q?=E4=B8=8B=E5=88=92=E7=BA=BF=E6=A0=87=E5=87=86=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO => TODO.MD | 98 +++++++++++++++++++------------------ g/frame/gins/gins.go | 4 +- g/g_logger.go | 16 +++++- g/net/ghttp/ghttp_server.go | 11 +++-- 4 files changed, 74 insertions(+), 55 deletions(-) rename TODO => TODO.MD (53%) diff --git a/TODO b/TODO.MD similarity index 53% rename from TODO rename to TODO.MD index ae76a2dcc..a45402e0c 100644 --- a/TODO +++ b/TODO.MD @@ -1,52 +1,51 @@ -ON THE WAY: -orm增加更多数据库支持; -增加对于数据表Model的封装; -更多数据库的ORM功能支持; -考虑gdb对象管理增加二级连接池特性,提高New&Close性能; -增加图形验证码支持,至少支持数字和英文字母; -增加热编译工具,提高开发环境的开发/测试效率(媲美PHP开发效率); -增加可选择性的orm tag特性,用以数据表记录与struct对象转换的键名属性映射; -ghttp.Response增加输出内容后自动退出当前请求机制,不需要用户手动return,参考beego如何实现; -Cookie&Session数据池化处理; -ghttp.Client增加proxy特性; -gtime增加对时区转换的封装,并简化失去转换时对类似+80500时区的支持; -orm增加sqlite对Save方法的支持(去掉触发器语句); -ghttp.Server增加Ip访问控制功能(DenyIps&AllowIps); -ghttp路由功能增加分组路由特性; -ghttp增加返回数据压缩机制; -gview中的template标签失效问题; -gfile文件stat信息使用gfsnotify进行缓存更新改进; -ghttp.Server增加proxy功能特性,本地proxy和远程proxy,本地即将路由规则映射;远程即反向代理; -gjson对大json数据的解析效率问题; -ghttp增加route name特性,并同时支持backend和template(提供内置函数)引用,可以通过RedirectRoute方法给定route name和路由参数跳转到指定的路由地址上; -ghttp.Client自动Close机制; -gvalid校验支持当第一个规则失败后便不再校验后续的规则,最好做成链式操作; -检查ghttp.Server超时问题; -gvalid增加支持对[]rune的长度校验(一个中文占3个字节); -ghttp.Request增加对输入参数的自动HtmlEncode机制; -常量命名风格根据golint进行修改; -开放rwmutex包,并将gjson的互斥锁使用自定义的mutex替换; -文档完善: - gconv struct tag、 - 控制器及执行对象注册的Init&Shut方法、 - ghttp.Response&ServeFile、gfcache、gproc shell执行、 - ghttp Server&Client basic auth、 - glog分类&日志等级&链式操作、gdb debug自动输出调试信息、gmlock内存锁、 -服务注册域名增加对泛域名的支持; -服务注册时判断方法定义满足规范时才执行绑定,否则提示WARN信息; -Cookie设置中文失效问题; -ghttp hook回调使用方式在注册路由比较多的时候,优先级可能使得开发者混乱,考虑方式便于管理; -使用gconv将slice映射到struct属性上,例如redis hscan的结果集; -项目参考: - https://github.com/namreg/godown - https://github.com/Masterminds/sprig -gform参考 https://gohouse.github.io/gorose/dist/index.html 进行改进 -完善配置管理章节,说明默认的配置文件更改方式; -完善gform配置管理说明,g.DB/Database和gdb.New的区别; +# ON THE WAY +1. orm增加更多数据库支持; +1. 增加对于数据表Model的封装; +1. 更多数据库的ORM功能支持; +1. 考虑gdb对象管理增加二级连接池特性,提高New&Close性能; +1. 增加图形验证码支持,至少支持数字和英文字母; +1. 增加热编译工具,提高开发环境的开发/测试效率(媲美PHP开发效率); +1. 增加可选择性的orm tag特性,用以数据表记录与struct对象转换的键名属性映射; +1. ghttp.Response增加输出内容后自动退出当前请求机制,不需要用户手动return,参考beego如何实现; +1. Cookie&Session数据池化处理; +1. ghttp.Client增加proxy特性; +1. gtime增加对时区转换的封装,并简化失去转换时对类似+80500时区的支持; +1. orm增加sqlite对Save方法的支持(去掉触发器语句); +1. ghttp.Server增加Ip访问控制功能(DenyIps&AllowIps); +1. ghttp路由功能增加分组路由特性; +1. ghttp增加返回数据压缩机制; +1. gview中的template标签失效问题; +1. gfile文件stat信息使用gfsnotify进行缓存更新改进; +1. ghttp.Server增加proxy功能特性,本地proxy和远程proxy,本地即将路由规则映射;远程即反向代理; +1. gjson对大json数据的解析效率问题; +1. ghttp增加route name特性,并同时支持backend和template(提供内置函数)引用,可以通过RedirectRoute方法给定route name和路由参数跳转到指定的路由地址上; +1. ghttp.Client自动Close机制; +1. gvalid校验支持当第一个规则失败后便不再校验后续的规则,最好做成链式操作; +1. 检查ghttp.Server超时问题; +1. gvalid增加支持对[]rune的长度校验(一个中文占3个字节); +1. ghttp.Request增加对输入参数的自动HtmlEncode机制; +1. 常量命名风格根据golint进行修改; +1. 开放rwmutex包,并将gjson的互斥锁使用自定义的mutex替换; +1. 文档完善: + - gconv struct tag、 + - 控制器及执行对象注册的Init&Shut方法、 + - ghttp.Response&ServeFile、gfcache、gproc shell执行、 + - ghttp Server&Client basic auth、 + - glog分类&日志等级&链式操作、gdb debug自动输出调试信息、gmlock内存锁、 +1. 服务注册域名增加对泛域名的支持; +1. Cookie设置中文失效问题; +1. ghttp hook回调使用方式在注册路由比较多的时候,优先级可能使得开发者混乱,考虑方式便于管理; +1. 使用gconv将slice映射到struct属性上,例如redis hscan的结果集; +1. 项目参考: + - https://github.com/namreg/godown + - https://github.com/Masterminds/sprig +1. gform参考 https://gohouse.github.io/gorose/dist/index.html 进行改进 -DONE: + + +# DONE 1. gconv完善针对不同类型的判断,例如:尽量减少sprintf("%v", xxx)来执行string类型的转换; 2. ghttp.Server请求执行中增加服务退出的方法,不再执行后续操作; 3. ghttp.Response对象完善并改进数据返回方法(Write/WriteString); @@ -89,4 +88,9 @@ DONE: 40. ghttp.Server的Cookie及Session锁机制优化(去掉map锁机制); 41. 解决glog串日志情况; 42. glog增加对日志文件名称的生成规则设定,支持时间格式规则; -43. ghttp日志增加客户端IP信息; \ No newline at end of file +43. ghttp日志增加客户端IP信息; +44. 完善gform配置管理说明,g.DB/Database和gdb.New的区别; +1. 完善配置管理章节,说明默认的配置文件更改方式; +1. 服务注册时判断方法定义满足规范时才执行绑定,否则提示WARN信息; + + diff --git a/g/frame/gins/gins.go b/g/frame/gins/gins.go index 285788985..2325bb396 100644 --- a/g/frame/gins/gins.go +++ b/g/frame/gins/gins.go @@ -74,7 +74,7 @@ func View(name...string) *gview.View { return instances.GetOrSetFuncLock(key, func() interface{} { path := gcmd.Option.Get("gf.viewpath") if path == "" { - path = genv.Get("gf.viewpath") + path = genv.Get("GF_VIEWPATH") if path == "" { path = gfile.SelfDir() } @@ -101,7 +101,7 @@ func Config(file...string) *gcfg.Config { func() interface{} { path := gcmd.Option.Get("gf.cfgpath") if path == "" { - path = genv.Get("gf.cfgpath") + path = genv.Get("GF_CFGPATH") if path == "" { path = gfile.SelfDir() } diff --git a/g/g_logger.go b/g/g_logger.go index ac9f1d6cf..50f71c478 100644 --- a/g/g_logger.go +++ b/g/g_logger.go @@ -6,7 +6,21 @@ package g -import "gitee.com/johng/gf/g/os/glog" +import ( + "gitee.com/johng/gf/g/os/gcmd" + "gitee.com/johng/gf/g/os/genv" + "gitee.com/johng/gf/g/os/glog" + "gitee.com/johng/gf/g/util/gconv" +) + +func init() { + if v := genv.Get("GF_DEBUG"); v != "" { + SetDebug(gconv.Bool(v)) + } + if v := gcmd.Option.Get("gf.debug"); v != "" { + SetDebug(gconv.Bool(v)) + } +} // 是否显示调试信息 func SetDebug(debug bool) { diff --git a/g/net/ghttp/ghttp_server.go b/g/net/ghttp/ghttp_server.go index 954864822..1ad12d116 100644 --- a/g/net/ghttp/ghttp_server.go +++ b/g/net/ghttp/ghttp_server.go @@ -296,7 +296,7 @@ func (s *Server) GetRouteMap() string { buf := bytes.NewBuffer(nil) table := tablewriter.NewWriter(buf) - table.SetHeader([]string{"SERVER", "ADDRESS", "DOMAIN", "METHOD", "ROUTE", "HANDLER", "HOOK"}) + table.SetHeader([]string{"SERVER", "ADDRESS", "DOMAIN", "METHOD", "P", "ROUTE", "HANDLER", "HOOK"}) table.SetRowLine(true) table.SetBorder(false) table.SetCenterSeparator("|") @@ -333,16 +333,17 @@ func (s *Server) GetRouteMap() string { addr += ",tls" + s.config.HTTPSAddr } for _, a := range m { - data := make([]string, 7) + data := make([]string, 8) for _, v := range a.Slice() { item := v.(*tableItem) data[0] = s.name data[1] = addr data[2] = item.domain data[3] = item.method - data[4] = item.route - data[5] = item.handler - data[6] = item.hook + data[4] = gconv.String(len(strings.Split(item.route, "/")) - 1) + data[5] = item.route + data[6] = item.handler + data[7] = item.hook table.Append(data) } }