I've set up a simple Go static file server with http.FileServer. If I have a directory structure like public > about > index.html, the server will correctly resolve /about to about > index.html, but it adds a trailing slash so the url becomes /about/.
Is there a simple way to remove these trailing slashes when using http.FileServer? Ultimately, it works either way - it's mostly just a personal preference to not have the trailing slashes if possible.
When you register the route
/about/an implicit route of/aboutis added (which redirects clients to/about/).To work around this, you can register two explicit routes:
/aboutto serve yourindex.html/about/to serve thehttp.FileServerto handle any HTML assets for the pagelike so:
https://play.golang.org/p/WLwLPV5WuJm