title: Go and Gorilla Mux NotFoundHandler not working
body: <p>I just can't get this NotFoundHandler to work. I'd like to serve a static file on every get request, given that it exists, otherwise serve index.html. Here's my simplified router at the moment:</p>
  
  <pre><code>func fooHandler() http.Handler {
    fn := func(w http.ResponseWriter, r *http.Request) {
      w.Write([]byte("Foo"))
    }
    return http.HandlerFunc(fn)
  }
  
  func notFound(w http.ResponseWriter, r *http.Request) {
    http.ServeFile(w, r, "public/index.html")
  }
  
  func main() {
    router = mux.NewRouter()
    fs := http.FileServer(http.Dir("public"))
  
    router.Handle("/foo", fooHandler())
    router.PathPrefix("/").Handler(fs)
    router.NotFoundHandler = http.HandlerFunc(notFound)
  
    http.ListenAndServe(":3000", router)
  }
  </code></pre>
  
  <p><em>/foo</em> works ok</p>
  
  <p><em>/file-that-exists</em> works ok</p>
  
  <p><em>/file-that-doesnt-exist</em> <strong>doesn't work</strong>
  - I get 404 page not found instead of index.html</p>
  
  <p>So what am I doing wrong here?</p>