mirror of
https://gitee.com/johng/gf
synced 2026-07-06 13:42:46 +08:00
完成ghttp.Server服务注册与事件回调注册的动态路由规则特性
This commit is contained in:
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
pattern := "/"
|
||||
pattern := "/:name/action"
|
||||
ghttp.GetServer().BindHookHandlerByMap(pattern, map[string]ghttp.HandlerFunc{
|
||||
"BeforeServe" : func(r *ghttp.Request){ fmt.Println("BeforeServe") },
|
||||
"AfterServe" : func(r *ghttp.Request){ fmt.Println("AfterServe") },
|
||||
|
||||
@ -7,19 +7,19 @@ func main() {
|
||||
r.Response.WriteString("hello world")
|
||||
})
|
||||
|
||||
//ghttp.GetServer().BindHandler("/:name/*any", func(r *ghttp.Request) {
|
||||
// r.Response.WriteString("any")
|
||||
ghttp.GetServer().BindHandler("/:name/*any", func(r *ghttp.Request) {
|
||||
r.Response.WriteString("any")
|
||||
r.Response.WriteString(r.GetQueryString("name"))
|
||||
r.Response.WriteString(r.GetQueryString("any"))
|
||||
})
|
||||
//ghttp.GetServer().BindHandler("/:name/action", func(r *ghttp.Request) {
|
||||
// r.Response.WriteString(r.GetQueryString("name"))
|
||||
// r.Response.WriteString(r.GetQueryString("any"))
|
||||
//})
|
||||
////ghttp.GetServer().BindHandler("/:name/action", func(r *ghttp.Request) {
|
||||
//// r.Response.WriteString(r.GetQueryString("name"))
|
||||
////})
|
||||
//ghttp.GetServer().BindHandler("/:name/:action/:aaa", func(r *ghttp.Request) {
|
||||
// r.Response.WriteString("name")
|
||||
// r.Response.WriteString(r.GetQueryString("name"))
|
||||
// r.Response.WriteString(r.GetQueryString("action"))
|
||||
//})
|
||||
ghttp.GetServer().BindHandler("/:name/:action/:aaa", func(r *ghttp.Request) {
|
||||
r.Response.WriteString("name")
|
||||
r.Response.WriteString(r.GetQueryString("name"))
|
||||
r.Response.WriteString(r.GetQueryString("action"))
|
||||
})
|
||||
ghttp.GetServer().SetPort(10000)
|
||||
ghttp.GetServer().Run()
|
||||
}
|
||||
Reference in New Issue
Block a user