Skip to content

Instantly share code, notes, and snippets.

@euforic
Created July 20, 2017 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save euforic/4d1151920fdc08fcbe8efcc731221661 to your computer and use it in GitHub Desktop.
Save euforic/4d1151920fdc08fcbe8efcc731221661 to your computer and use it in GitHub Desktop.
Add pprof to a labstack/echo server
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