Files
gf/geg/net/ghttp/server/hooks/hooks4.go
2019-04-03 00:03:46 +08:00

33 lines
734 B
Go

package main
import (
"github.com/gogf/gf/g"
"github.com/gogf/gf/g/net/ghttp"
"github.com/gogf/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()
}