]> Cypherpunks repositories - gostls13.git/commitdiff
expvar: export http.Handler
authorAnders Pearson <anders@columbia.edu>
Sun, 3 Jul 2016 13:22:06 +0000 (14:22 +0100)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sun, 25 Sep 2016 23:34:28 +0000 (23:34 +0000)
Add a method to expose the handler to allow it to be installed at a
non-standard location or used with a different ServeMux.

fixes #15030

Change-Id: If778ad6fcc200f124a05c0a493511e364fca6078
Reviewed-on: https://go-review.googlesource.com/24722
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/expvar/expvar.go

index d5465c518f81d98b95d8b26370a0c12bbec34bd5..fde763d7cee5d95797ba0d08083ecd561c6dd293 100644 (file)
@@ -322,6 +322,13 @@ func expvarHandler(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintf(w, "\n}\n")
 }
 
+// Handler returns the expvar HTTP Handler.
+//
+// This is only needed to install the handler in a non-standard location.
+func Handler() http.Handler {
+       return http.HandlerFunc(expvarHandler)
+}
+
 func cmdline() interface{} {
        return os.Args
 }