Files
gf/geg/frame/mvc/controller/user/user.go
2017-12-28 15:21:25 +08:00

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