fix: workaround for routes like /play, /admin which really should have a trailing /

This commit is contained in:
Settel 2022-03-09 09:09:04 +01:00
parent a74717788e
commit 5798132e9b
2 changed files with 9 additions and 1 deletions

View File

@ -15,6 +15,14 @@ func FileHandler(w http.ResponseWriter, req *http.Request) {
} }
uri = uri[1:] uri = uri[1:]
data, err := Resources.Asset(uri) data, err := Resources.Asset(uri)
if err != nil && uri[len(uri)-1] != '/' {
// workaround for routes like "/play" which really should be "/play/index.html"
uriFolder := uri + "/index.html"
data, err = Resources.Asset(uriFolder)
if err == nil {
uri = uriFolder
}
}
if err != nil { if err != nil {
fmt.Printf("%s: %v\n", uri, err) fmt.Printf("%s: %v\n", uri, err)
http.NotFoundHandler().ServeHTTP(w, req) http.NotFoundHandler().ServeHTTP(w, req)

View File

@ -1,3 +1,3 @@
package Resources package Resources
//go:generate go-bindata -pkg Resources -o dist-generated.go --prefix ../../../client/dist/ ../../../client/dist/ ../../../client/dist/_nuxt/ ../../../client/dist/play ../../../client/dist/admin ../../../client/dist/fonts/dosis ../../../client/dist/fonts/wendy-one //go:generate go-bindata -pkg Resources -o dist-generated.go --prefix ../../../client/dist/ ../../../client/dist/ ../../../client/dist/_nuxt/ ../../../client/dist/play/ ../../../client/dist/admin/ ../../../client/dist/fonts/dosis ../../../client/dist/fonts/wendy-one