I have made a app where I need to serve the same files to multiple routes because the front end is a React app. I have been using gorilla mux for the router. The file structure is as follows:
main.go
build/
| index.html
| service-worker.js
static/
| js/
| main.js
| css/
| main.css
The files are refereed to assuming they are at the root of the file directory. So in the html file they are requested like '/static/js/main.js'.
In main my routes are defined as follows:
r.PathPrefix("/student").Handler(http.StripPrefix("/student",http.FileServer(http.Dir("build/")))).Methods("GET")
r.PathPrefix("/").Handler(http.FileServer(http.Dir("build/"))).Methods("GET")
This way I get the index.html file served in both the '/' and '/student' route. If I have them the other way around the '/student' path gets a 404 error. So what I am asking is there another way to serve the same content for both of these routes in order for me not have to define a route for each view I will have in my web app.