I'm using Gorilla Mux as my web server.
I define a bunch of routes, but if no route is matched, I want it to serve my index.html file.
func (mgr *ApiMgr) InstantiateRestRtr() *mux.Router {
mgr.pRestRtr = mux.NewRouter().StrictSlash(true)
mgr.pRestRtr.PathPrefix("/api/").Handler(http.StripPrefix("/api/",
http.FileServer(http.Dir(mgr.fullPath+"/docsui"))))
for _, route := range mgr.restRoutes {
var handler http.Handler
handler = Logger(route.HandlerFunc, route.Name)
mgr.pRestRtr.Methods(route.Method)
.Path(route.Pattern)
.Name(route.Name)
.Handler(handler)
}
// Here I want to catch any unmatched routes, and serve my '/site/index.html` file.
// How can I do this?
return mgr.pRestRtr
}