| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "github.com/gin-gonic/gin" |
| 5 | |
| 6 | "github.com/DeanThompson/ginpprof" |
| 7 | ) |
| 8 | |
| 9 | func main() { |
| 10 | router := gin.Default() |
| 11 | |
| 12 | router.GET("/ping", func(c *gin.Context) { |
| 13 | c.String(200, "pong") |
| 14 | }) |
| 15 | |
| 16 | // automatically add routers for net/http/pprof |
| 17 | // e.g. /debug/pprof, /debug/pprof/heap, etc. |
| 18 | ginpprof.Wrap(router) |
| 19 | |
| 20 | // ginpprof also plays well with *gin.RouterGroup |
| 21 | // group := router.Group("/debug/pprof") |
| 22 | // ginpprof.WrapGroup(group) |
| 23 | |
| 24 | router.Run(":8080") |
| 25 | } |