github.com/gogf/gf@v1.16.9/.example/net/ghttp/server/router/router5.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/gogf/gf/frame/g"
     7  	"github.com/gogf/gf/net/ghttp"
     8  )
     9  
    10  func main() {
    11  	s := g.Server()
    12  	s.BindHookHandler("/*any", ghttp.HookBeforeServe, func(r *ghttp.Request) {
    13  		fmt.Println(r.Router)
    14  		fmt.Println(r.Get("customer_id"))
    15  	})
    16  	s.BindHandler("/admin/customer/{customer_id}/edit", func(r *ghttp.Request) {
    17  		r.Response.Writeln(r.Get("customer_id"))
    18  		r.Response.Writeln(r.Router.Uri)
    19  	})
    20  	s.BindHandler("/admin/customer/{customer_id}/disable", func(r *ghttp.Request) {
    21  		r.Response.Writeln(r.Get("customer_id"))
    22  		r.Response.Writeln(r.Router.Uri)
    23  	})
    24  	s.SetPort(8199)
    25  	s.Run()
    26  }