Created
July 20, 2017 23:34
-
-
Save euforic/4d1151920fdc08fcbe8efcc731221661 to your computer and use it in GitHub Desktop.
Add pprof to a labstack/echo server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package server | |
import ( | |
"fmt" | |
"net/http" | |
_ "net/http/pprof" | |
"github.com/labstack/echo" | |
) | |
func New() *echo.Echo { | |
e := echo.New() | |
dbg := e.Group("/debug") | |
dbg.GET("/pprof/*", func(c echo.Context) error { | |
w := c.Response().Writer | |
r := c.Request() | |
if h, p := http.DefaultServeMux.Handler(r); p != "" { | |
h.ServeHTTP(w, r) | |
return nil | |
} | |
return echo.NewHTTPError(http.StatusNotFound) | |
}) | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment