diff --git a/TODO b/TODO index f00d544ce..0824aa2cb 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,12 @@ +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请求执行中增加服务退出的方法,不再执行后续操作; \ No newline at end of file +3. ghttp.Server请求执行中增加服务退出的方法,不再执行后续操作; +4. 增加fsnotify包支持; +5. 改进gcfg和gview的文件自动更新机制; +6. 将模板变量进行暴露,以便应用端可以进行灵活控制; \ No newline at end of file diff --git a/g/frame/gmvc/view.go b/g/frame/gmvc/view.go index 274f572e0..6192e73d4 100644 --- a/g/frame/gmvc/view.go +++ b/g/frame/gmvc/view.go @@ -55,9 +55,9 @@ func (view *View) Parse(file string) ([]byte, error) { } // 直接解析模板内容,并返回解析后的内容 -func (view *View) ParseContent(name string, content string) ([]byte, error) { +func (view *View) ParseContent(content string) ([]byte, error) { view.mu.RLock() - buffer, err := view.view.ParseContent(name, content, view.data) + buffer, err := view.view.ParseContent(content, view.data) view.mu.RUnlock() return buffer, err } diff --git a/g/net/ghttp/http_server_pprof.go b/g/net/ghttp/http_server_pprof.go index 04cb5e190..0ab008b1c 100644 --- a/g/net/ghttp/http_server_pprof.go +++ b/g/net/ghttp/http_server_pprof.go @@ -26,7 +26,7 @@ func (p *utilpprof) Index(r *Request) { } if len(action) == 0 { view := gins.View() - buffer, _ := view.ParseContent("ghttp_pprof", ` + buffer, _ := view.ParseContent(` gf ghttp pprof diff --git a/g/os/gview/gview.go b/g/os/gview/gview.go index d451f5a02..12c877e42 100644 --- a/g/os/gview/gview.go +++ b/g/os/gview/gview.go @@ -16,6 +16,8 @@ import ( "gitee.com/johng/gf/g/os/gfile" "gitee.com/johng/gf/g/container/gmap" "gitee.com/johng/gf/g/container/gtype" + "gitee.com/johng/gf/g/encoding/ghash" + "gitee.com/johng/gf/g/util/gconv" ) // 视图对象 @@ -88,7 +90,8 @@ func (view *View) Parse(file string, params map[string]interface{}) ([]byte, err } // 直接解析模板内容,返回解析后的内容 -func (view *View) ParseContent(name string, content string, params map[string]interface{}) ([]byte, error) { +func (view *View) ParseContent(content string, params map[string]interface{}) ([]byte, error) { + name := gconv.String(ghash.BKDRHash64([]byte(content))) buffer := bytes.NewBuffer(nil) if tpl, err := template.New(name).Funcs(view.getFuncs()).Parse(content); err != nil { return nil, err diff --git a/geg/net/ghttp/pprof.go b/geg/net/ghttp/pprof.go index 0bab3f3c5..aae3ef5a1 100644 --- a/geg/net/ghttp/pprof.go +++ b/geg/net/ghttp/pprof.go @@ -6,7 +6,7 @@ import ( func main() { s := ghttp.GetServer() - s.EnablePprof("/debug/pprof2") + s.EnablePprof() s.BindHandler("/", func(r *ghttp.Request){ r.Response.Writeln("哈喽世界!") })