I want to have an optional URL variable in the route. I can't seem to find a way to use the mux package. Here is my current route:
func main() { r := mux.NewRouter() r.HandleFunc("/view/{id:[0-9]+}", MakeHandler(ViewHandler)) http.Handle("/", r) http.ListenAndServe(":8080", nil) }
It works when localhost:8080/view/1 URL localhost:8080/view/1 . I want it to accept even if there is no id , so if I go into localhost:8080/view , it will work anyway. Thoughts?
source share