From c149588a5bb64396455987641a3605c166b4377a Mon Sep 17 00:00:00 2001 From: Cem Ezberci Date: Thu, 1 Mar 2018 01:43:54 +0100 Subject: [PATCH] Remove replicated expvar handler (#805) expvar package exports Handler which can be directly used instead of copying the expvarHandler function. --- api/server/profile.go | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/api/server/profile.go b/api/server/profile.go index ab8c43584..1bef38d7f 100644 --- a/api/server/profile.go +++ b/api/server/profile.go @@ -2,31 +2,14 @@ package server import ( "expvar" - "fmt" - "net/http" "net/http/pprof" "github.com/gin-gonic/gin" ) -// Replicated from expvar.go as not public. -func expVars(w http.ResponseWriter, r *http.Request) { - first := true - w.Header().Set("Content-Type", "application/json; charset=utf-8") - fmt.Fprintf(w, "{\n") - expvar.Do(func(kv expvar.KeyValue) { - if !first { - fmt.Fprintf(w, ",\n") - } - first = false - fmt.Fprintf(w, "%q: %s", kv.Key, kv.Value) - }) - fmt.Fprintf(w, "\n}\n") -} - func profilerSetup(router *gin.Engine, path string) { engine := router.Group(path) - engine.Any("/vars", gin.WrapF(expVars)) + engine.Any("/vars", gin.WrapF(expvar.Handler().ServeHTTP)) engine.Any("/pprof/", gin.WrapF(pprof.Index)) engine.Any("/pprof/cmdline", gin.WrapF(pprof.Cmdline)) engine.Any("/pprof/profile", gin.WrapF(pprof.Profile))