fix25_content.go.txt 664 B

123456789101112131415161718192021222324252627282930
  1. package testdata
  2. import (
  3. "fmt"
  4. "testing"
  5. "time"
  6. "github.com/gogf/gf/v2/frame/g"
  7. "github.com/gogf/gf/v2/net/ghttp"
  8. "github.com/gogf/gf/v2/test/gtest"
  9. "github.com/gogf/gf/v2/util/guid"
  10. )
  11. func Test_Router_Hook_Multi(t *testing.T) {
  12. s := g.Server(guid.S())
  13. s.BindHandler("/multi-hook", func(r *ghttp.Request) {
  14. r.Response.Write("show")
  15. })
  16. s.BindHookHandlerByMap("/multi-hook", map[string]ghttp.HandlerFunc{
  17. ghttp.HookBeforeServe: func(r *ghttp.Request) {
  18. r.Response.Write("1")
  19. },
  20. })
  21. s.BindHookHandlerByMap("/multi-hook/{id}", map[string]ghttp.HandlerFunc{
  22. ghttp.HookBeforeServe: func(r *ghttp.Request) {
  23. r.Response.Write("2")
  24. },
  25. })
  26. }