title: Gorilla mux http package
body: <p>I'm using Gorilla mux as my router and dispatcher in my golang apps and I have a -I think- simple question:</p>
  
  <p>In my main, I create a router: <code>r := mux.NewRouter()</code>. A few lines further, I register a handler: <code>r.HandleFunc("/", doSomething)</code>.</p>
  
  <p>So far so good, but now my problem is that I have a package which adds handlers to the <code>http package</code> of Golang and not to my mux router. Like this:</p>
  
  <pre><code>func AddInternalHandlers() {
      http.HandleFunc("/internal/selfdiagnose.html", handleSelfdiagnose)
      http.HandleFunc("/internal/selfdiagnose.xml", handleSelfdiagnose)
      http.HandleFunc("/internal/selfdiagnose.json", handleSelfdiagnose)
  }
  </code></pre>
  
  <p>As you can see, it adds handles to the http.HandleFunc and not to the mux-handleFunc. Any idea how I can fix this without touching the package itself?</p>
  
  <p><strong>Working example</strong></p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "log"
  
      "net/http"
  
      selfdiagnose "github.com/emicklei/go-selfdiagnose"
      "github.com/gorilla/mux"
  )
  
  func homeHandler(w http.ResponseWriter, r *http.Request) {
      log.Println("home")
  }
  
  func main() {
      r := mux.NewRouter()
      r.HandleFunc("/", homeHandler)
  
      selfdiagnose.AddInternalHandlers()
  
    // when handler (nil) gets replaced with mux (r), then the
    // handlers in package selfdiagnose are not "active"
      err := http.ListenAndServe(fmt.Sprintf("%s:%d", "localhost", 8080), nil)
      if err != nil {
          log.Println(err)
      }
  
  }
  </code></pre>