Gin: [HELP WANTED] How to route multi URL in same prefix with single handler

Created on 12 Dec 2017  路  2Comments  路  Source: gin-gonic/gin

Hey guys, I get a problem here

I want to use the gin for /debug/pprof and /debug/vars routing. I use gin.WrapH(http.DefaultServeMux) as the handler for prefix routing rule.

But in my code, I can not reach /debug/pprof/heap. And there is less guide in document for me.

I wonder if here are some misunderstand in my code

        router.GET("/status", Status)
        rg := router.Group("/debug", gin.WrapH(http.DefaultServeMux))  // here!
        rg.GET("/pprof", gin.WrapH(http.DefaultServeMux))
        rg.GET("/vars", gin.WrapH(http.DefaultServeMux))

Most helpful comment

Here's how I did it.

router.GET("/debug/pprof/*any", gin.WrapH(http.DefaultServeMux))

Without *any catch-all parameter, routes like /debug/pprof/heap won't match.

All 2 comments

Here's how I did it.

router.GET("/debug/pprof/*any", gin.WrapH(http.DefaultServeMux))

Without *any catch-all parameter, routes like /debug/pprof/heap won't match.

@hassansin that's what I did, thx bro.

closed

Was this page helpful?
0 / 5 - 0 ratings