I would expect index.html handling to work out of the box, but it doesn't seem that way.
package main
import (
"github.com/gobuffalo/logger"
"github.com/gobuffalo/packr/v2"
"github.com/gobuffalo/packr/v2/plog"
"net/http"
)
func main() {
plog.Logger = logger.New(logger.DebugLevel)
box := packr.New("test", "./broken_index")
http.Handle("/", http.FileServer(box))
http.ListenAndServe(":3000", nil)
}
under the broken_index directory I have an index.html and an index.htm, and the same under a sub directory: broken_index/sub an index.html and an index.htm.
As http.ServeFile redirects index.html calls to the / and http.serveFile contains the logic to check for existence of index.html under directories if f.IsDir(), I would expect "/", "/index.html", "/sub", "/sub/index.html" to work, but they come back with different errors:
"/" redirects to "http://localhost:3000//" and ends up in too many redirect calls.
"/sub/index.html" returns an empty response:
curl http://localhost:3000/sub/index.html -v Sat Aug 31 16:44:00 2019
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 3000 (#0)
> GET /sub/index.html HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Location: ./
< Date: Sat, 31 Aug 2019 23:44:12 GMT
< Content-Length: 0
<
* Connection #0 to host localhost left intact
I believe the underlying cause might be related to #211.
The /index.htm and /sub/index.htm urls work (just as a sanity check for my wiring/folder naming).
I would expect
index.htmlhandling to work out of the box, but it doesn't seem that way.under the
broken_indexdirectory I have anindex.htmland anindex.htm, and the same under a sub directory:broken_index/subanindex.htmland anindex.htm.As
http.ServeFileredirectsindex.htmlcalls to the/andhttp.serveFilecontains the logic to check for existence ofindex.htmlunder directories iff.IsDir(), I would expect "/", "/index.html", "/sub", "/sub/index.html" to work, but they come back with different errors:"/" redirects to "http://localhost:3000//" and ends up in too many redirect calls.
"/sub/index.html" returns an empty response:
I believe the underlying cause might be related to #211.
The
/index.htmand/sub/index.htmurls work (just as a sanity check for my wiring/folder naming).