Files
gf/geg/frame/mvc/controller/user/user.go
2017-12-26 11:46:48 +08:00

44 lines
1001 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package user
import (
"gitee.com/johng/gf/g/net/ghttp"
"gitee.com/johng/gf/g/frame/gmvc"
)
// 定义业务相关的控制器对象
type ControllerUser struct {
gmvc.Controller
}
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").BindObjectRest("/test", &T{})
ghttp.GetServer("johng").BindController("/user", &ControllerUser{})
}
// 定义操作逻辑
func (c *ControllerUser) Info() {
c.Response.WriteString("hello world!")
//c.View.Assign("name", "john")
//c.View.Display("user/index")
}