ghttp支持绑定实例化对象

This commit is contained in:
John
2017-12-26 11:46:48 +08:00
parent b8f1592000
commit a8faa2d3e8
3 changed files with 120 additions and 32 deletions

View File

@ -10,15 +10,25 @@ type ControllerUser struct {
gmvc.Controller
}
func Test(s *ghttp.Server, r *ghttp.ClientRequest, w *ghttp.ServerResponse) {
type T struct {
}
func (t *T) Test(s *ghttp.Server, r *ghttp.ClientRequest, w *ghttp.ServerResponse) {
w.WriteString("Test")
w.Output()
}
func (t *T) Get(s *ghttp.Server, r *ghttp.ClientRequest, w *ghttp.ServerResponse) {
w.WriteString("Http Method GET")
w.Output()
}
// 初始化控制器对象并绑定操作到Web Server
func init() {
//ghttp.GetServer("johng").Domain("localhost").BindHandler("/user", u.Info)
ghttp.GetServer("johng").BindHandler("/test", Test)
//ghttp.GetServer("johng").BindHandler("/test", Test)
ghttp.GetServer("johng").BindObjectRest("/test", &T{})
ghttp.GetServer("johng").BindController("/user", &ControllerUser{})
}