File tree Expand file tree Collapse file tree 3 files changed +50
-0
lines changed
Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,34 @@ func main() {
5454}
5555```
5656
57+ ### custom router group
58+
59+ ``` go
60+ package main
61+
62+ import (
63+ " net/http"
64+
65+ " github.com/gin-contrib/pprof"
66+ " github.com/gin-gonic/gin"
67+ )
68+
69+ func main () {
70+ router := gin.Default ()
71+ pprof.Register (router)
72+ adminGroup := r.Group (" /admin" , func (c *gin.Context ) {
73+ if c.Request .Header .Get (" Authorization" ) != " foobar" {
74+ c.AbortWithStatus (http.StatusForbidden )
75+ return
76+ }
77+ c.Next ()
78+ })
79+ pprof.RouteRegister (adminGroup, " pprof" )
80+ router.Run (" :8080" )
81+ }
82+
83+ ```
84+
5785### Use the pprof tool
5886
5987Then use the pprof tool to look at the heap profile:
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "net/http"
5+
6+ "github.com/gin-contrib/pprof"
7+ "github.com/gin-gonic/gin"
8+ )
9+
10+ func main () {
11+ router := gin .Default ()
12+ pprof .Register (router )
13+ adminGroup := r .Group ("/admin" , func (c * gin.Context ) {
14+ if c .Request .Header .Get ("Authorization" ) != "foobar" {
15+ c .AbortWithStatus (http .StatusForbidden )
16+ return
17+ }
18+ c .Next ()
19+ })
20+ pprof .RouteRegister (adminGroup , "pprof" )
21+ router .Run (":8080" )
22+ }
File renamed without changes.
You can’t perform that action at this time.
0 commit comments