so I've had some trouble with this lately... Here is my code:
https://gist.github.com/anonymous/af1e6d922ce22597099521a4b2cfa16f
My problem: I'm trying to serve up some HTML files from a folder: ./docs/html
. My folder structure:
.
├── docs
│ └── html
│ ├── index.html
│ └── rest.html
└── main.go
You'll notice in the gist I am calling the ServeHTTP
method on the http.HandlerFunc
ServeDocs, which is then going through a router (mux.Router
). The problem I'm having is for some reason the only file being served up at localhost:8080/
is index.html
, and when I navigate to localhost:8080/rest.html
I get a 404.
The really odd part is that when I remove all the router code and do something like the following:
fs := http.FileServer(http.Dir("./docs/html"))
http.Handle("/", fs)
log.Println("Listening...")
http.ListenAndServe(":3000", nil)
Everything works as it should. Anybody know what's going on? I've spent hours trying to figure this out and I've finally given up.