0

Actually I'm having exactly the same symptom/issue as question 46403678: The links returned are invalid. The solution posted there appears to require the use of the Gorilla mux:

r.PathPrefix("/download/").Handler(
    http.StripPrefix("/download", http.FileServer(http.Dir(dirPath))),
).Methods("GET")

I'm looking for a solution that doesn't require importing any 3rd party packages.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
tpa
  • 1
  • 2
  • 2
    The [answer you reference](https://stackoverflow.com/a/46404016/11810946) provides a "simple file server app using only the standard library" at the end that appears to address your question? [This answer](https://stackoverflow.com/a/27946132/11810946) provides additional info. It will be easier to help you if you post [your code](https://stackoverflow.com/help/minimal-reproducible-example). – Brits Jan 16 '22 at 04:58
  • The example you mention is what I have been working with. The generated html links still do not include the containing directory in the path (as per the original question), however, by adding a second handler for "/dl/" I now have a functioning example. – tpa Jan 16 '22 at 06:47
  • I'm a little confused as the example has a handler for `/dl/` (`http.Handle("/dl/",...`). Glad you have found a solution but if ask another question please include your code (this makes it easier to answer and also means the answers are more likely to be of use to others). – Brits Jan 16 '22 at 07:46
  • 1
    to clarify: I created two handlers, one for the "/dl" and one for the "/dl/", using the same code, to achieve the desired results. Criticism understood and accepted. I'm new to this environment and UI, I hope to improve over time. – tpa Jan 18 '22 at 21:12

0 Answers0