Original post

Happy Halloween fellow Gophers,

I’m setting up a new server with httprouter (julienschmidt’s) and I need to direct users to the index.html page, but the catch-all route doesn’t seem to work. I am trying to serve the index handler for all of the paths other than the API REST endpoints, so that the ReactJS application deals with the routing.

 mux := httprouter.New() // Serves the css files called by HTML files mux.ServeFiles("/assets/css/*filepath", http.Dir(config.Path+"client/dist/assets/css/")) // Serves the javascript files called by HTML files mux.ServeFiles("/assets/js/*filepath", http.Dir(config.Path+"client/dist/assets/js/")) // Serves the images called by HTML files mux.ServeFiles("/assets/img/*filepath", http.Dir(config.Path+"client/dist/assets/img/")) mux.GET("/favicon.ico", Favicon) mux.GET("/*all", index) 

I get the following error message:

wildcard segment '*all' conflicts with existing children in path '/*all' 

This is a pretty common use case, and I’ve read other blogs talking about this setup, but they use gorilla/mux or some other router, but what can I say….I have a……NEED FOR SPEED! VROOM VROOM! (sorry, couldn’t help myself)

submitted by /u/comebacknader
[link] [comments]