Files
gf/geg/net/ghttp/server/hooks/hooks4.go
2018-08-03 15:22:31 +08:00

32 lines
853 B
Go

package main
import (
"gitee.com/johng/gf/g"
"gitee.com/johng/gf/g/net/ghttp"
"gitee.com/johng/gf/g/os/glog"
)
func main() {
s := g.Server()
s.BindHandler("/priority/show", func(r *ghttp.Request) {
r.Response.Write("priority test")
})
s.BindHookHandlerByMap("/priority/:name", map[string]ghttp.HandlerFunc {
"BeforeServe" : func(r *ghttp.Request) {
glog.Println(r.Router.Uri)
},
})
s.BindHookHandlerByMap("/priority/*any", map[string]ghttp.HandlerFunc {
"BeforeServe" : func(r *ghttp.Request) {
glog.Println(r.Router.Uri)
},
})
s.BindHookHandlerByMap("/priority/show", map[string]ghttp.HandlerFunc {
"BeforeServe" : func(r *ghttp.Request) {
glog.Println(r.Router.Uri)
},
})
s.SetPort(8199)
s.Run()
}