gf/geg/frame/mvc/controller/demo/domain.go

22 lines
570 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 demo
import (
"gitee.com/johng/gf/g/net/ghttp"
)
type ControllerDomain struct {}
// 初始化控制器对象并绑定操作到Web Server
func init() {
// 只有localhost域名下才能访问该对象
// 对应URL为http://localhost:8199/test/show
// 通过该地址将无法访问到内容http://127.0.0.1:8199/test/show
ghttp.GetServer().Domain("localhost").BindObject("/domain", &ControllerDomain{})
}
// 用于对象映射
func (d *ControllerDomain) Show(r *ghttp.Request) {
r.Response.Write("It's show time bibi!")
}