mirror of
https://gitee.com/johng/gf
synced 2026-07-04 04:52:48 +08:00
ghttp支持绑定实例化对象
This commit is contained in:
@ -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{})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user