title: How to create a route with optional url var using gorilla mux?
body: <p>I want to have an optional URL variable in route. I can't seem to find a way using mux package. Here's my current route:</p>
  
  <pre><code>func main() {
      r := mux.NewRouter()
      r.HandleFunc("/view/{id:[0-9]+}", MakeHandler(ViewHandler))
      http.Handle("/", r)
      http.ListenAndServe(":8080", nil)
  }
  </code></pre>
  
  <p>It works when the url is <code>localhost:8080/view/1</code>. I want it to accept even if there's no <code>id</code> so that if I enter <code>localhost:8080/view</code> it'll still work. Thoughts?</p>