mirror of
https://github.com/labstack/echo.git
synced 2025-07-17 01:43:02 +02:00
Improve filesystem support (Go 1.16+). Add field echo.Filesystem, methods: echo.FileFS, echo.StaticFS, group.FileFS, group.StaticFS. Following methods will use echo.Filesystem to server files: echo.File, echo.Static, group.File, group.Static, Context.File
This commit is contained in:
17
echo_test.go
17
echo_test.go
@ -211,7 +211,6 @@ func TestEchoStatic(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEchoStaticRedirectIndex(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
e := New()
|
||||
|
||||
// HandlerFunc
|
||||
@ -220,23 +219,25 @@ func TestEchoStaticRedirectIndex(t *testing.T) {
|
||||
errCh := make(chan error)
|
||||
|
||||
go func() {
|
||||
errCh <- e.Start("127.0.0.1:1323")
|
||||
errCh <- e.Start(":0")
|
||||
}()
|
||||
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
err := waitForServerStart(e, errCh, false)
|
||||
assert.NoError(t, err)
|
||||
|
||||
if resp, err := http.Get("http://127.0.0.1:1323/static"); err == nil {
|
||||
addr := e.ListenerAddr().String()
|
||||
if resp, err := http.Get("http://" + addr + "/static"); err == nil { // http.Get follows redirects by default
|
||||
defer resp.Body.Close()
|
||||
assert.Equal(http.StatusOK, resp.StatusCode)
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
if body, err := ioutil.ReadAll(resp.Body); err == nil {
|
||||
assert.Equal(true, strings.HasPrefix(string(body), "<!doctype html>"))
|
||||
assert.Equal(t, true, strings.HasPrefix(string(body), "<!doctype html>"))
|
||||
} else {
|
||||
assert.Fail(err.Error())
|
||||
assert.Fail(t, err.Error())
|
||||
}
|
||||
|
||||
} else {
|
||||
assert.Fail(err.Error())
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
if err := e.Close(); err != nil {
|
||||
|
Reference in New Issue
Block a user