1
0
mirror of https://github.com/labstack/echo.git synced 2024-11-24 08:22:21 +02:00

reverts #1671 changes

This commit is contained in:
toimtoimtoim 2020-12-17 02:20:26 +02:00
parent 655596b1b9
commit 547ca5ca1e
2 changed files with 0 additions and 44 deletions

View File

@ -500,7 +500,6 @@ func (common) static(prefix, root string, get func(string, HandlerFunc, ...Middl
} }
return c.File(name) return c.File(name)
} }
get(prefix, h)
if prefix == "/" { if prefix == "/" {
return get(prefix+"*", h) return get(prefix+"*", h)
} }

View File

@ -102,15 +102,6 @@ func TestEchoStatic(t *testing.T) {
expectHeaderLocation: "/folder/", expectHeaderLocation: "/folder/",
expectBodyStartsWith: "", expectBodyStartsWith: "",
}, },
{
name: "Directory Redirect with non-root path",
givenPrefix: "/static",
givenRoot: "_fixture",
whenURL: "/static",
expectStatus: http.StatusMovedPermanently,
expectHeaderLocation: "/static/",
expectBodyStartsWith: "",
},
{ {
name: "Directory with index.html", name: "Directory with index.html",
givenPrefix: "/", givenPrefix: "/",
@ -170,40 +161,6 @@ func TestEchoStatic(t *testing.T) {
} }
} }
func TestEchoStaticRedirectIndex(t *testing.T) {
assert := assert.New(t)
e := New()
// HandlerFunc
e.Static("/static", "_fixture")
errCh := make(chan error)
go func() {
errCh <- e.Start("127.0.0.1:1323")
}()
time.Sleep(200 * time.Millisecond)
if resp, err := http.Get("http://127.0.0.1:1323/static"); err == nil {
defer resp.Body.Close()
assert.Equal(http.StatusOK, resp.StatusCode)
if body, err := ioutil.ReadAll(resp.Body); err == nil {
assert.Equal(true, strings.HasPrefix(string(body), "<!doctype html>"))
} else {
assert.Fail(err.Error())
}
} else {
assert.Fail(err.Error())
}
if err := e.Close(); err != nil {
t.Fatal(err)
}
}
func TestEchoFile(t *testing.T) { func TestEchoFile(t *testing.T) {
e := New() e := New()
e.File("/walle", "_fixture/images/walle.png") e.File("/walle", "_fixture/images/walle.png")