Skip to content
This repository was archived by the owner on Jun 25, 2022. It is now read-only.
This repository was archived by the owner on Jun 25, 2022. It is now read-only.

index.html handling issues #235

@balopat

Description

@balopat

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions