pprof middleware
()
| 23 | |
| 24 | // pprof middleware |
| 25 | func pprofRouter() rex.Handle { |
| 26 | return func(ctx *rex.Context) any { |
| 27 | switch ctx.R.URL.Path { |
| 28 | case "/debug/pprof/cmdline": |
| 29 | return http.HandlerFunc(pprof.Cmdline) |
| 30 | case "/debug/pprof/profile": |
| 31 | return http.HandlerFunc(pprof.Profile) |
| 32 | case "/debug/pprof/symbol": |
| 33 | return http.HandlerFunc(pprof.Symbol) |
| 34 | case "/debug/pprof/trace": |
| 35 | return http.HandlerFunc(pprof.Trace) |
| 36 | default: |
| 37 | if strings.HasPrefix(ctx.R.URL.Path, "/debug/pprof/") { |
| 38 | return http.HandlerFunc(pprof.Index) |
| 39 | } |
| 40 | return rex.Next() |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | type MockEmbedFS struct{} |
| 46 |