Skip to content

Commit 829e821

Browse files
authored
Merge pull request #1722 from aldas/revert_pr_1674
Revert #1674 - failing tests
2 parents ea31edb + 547ca5c commit 829e821

File tree

4 files changed

+4
-78
lines changed

4 files changed

+4
-78
lines changed

echo.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,6 @@ func (common) static(prefix, root string, get func(string, HandlerFunc, ...Middl
500500
}
501501
return c.File(name)
502502
}
503-
get(prefix, h)
504503
if prefix == "/" {
505504
return get(prefix+"*", h)
506505
}

echo_test.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,6 @@ func TestEchoStatic(t *testing.T) {
102102
expectHeaderLocation: "/folder/",
103103
expectBodyStartsWith: "",
104104
},
105-
{
106-
name: "Directory Redirect with non-root path",
107-
givenPrefix: "/static",
108-
givenRoot: "_fixture",
109-
whenURL: "/static",
110-
expectStatus: http.StatusMovedPermanently,
111-
expectHeaderLocation: "/static/",
112-
expectBodyStartsWith: "",
113-
},
114105
{
115106
name: "Directory with index.html",
116107
givenPrefix: "/",
@@ -170,40 +161,6 @@ func TestEchoStatic(t *testing.T) {
170161
}
171162
}
172163

173-
func TestEchoStaticRedirectIndex(t *testing.T) {
174-
assert := assert.New(t)
175-
e := New()
176-
177-
// HandlerFunc
178-
e.Static("/static", "_fixture")
179-
180-
errCh := make(chan error)
181-
182-
go func() {
183-
errCh <- e.Start("127.0.0.1:1323")
184-
}()
185-
186-
time.Sleep(200 * time.Millisecond)
187-
188-
if resp, err := http.Get("http://127.0.0.1:1323/static"); err == nil {
189-
defer resp.Body.Close()
190-
assert.Equal(http.StatusOK, resp.StatusCode)
191-
192-
if body, err := ioutil.ReadAll(resp.Body); err == nil {
193-
assert.Equal(true, strings.HasPrefix(string(body), "<!doctype html>"))
194-
} else {
195-
assert.Fail(err.Error())
196-
}
197-
198-
} else {
199-
assert.Fail(err.Error())
200-
}
201-
202-
if err := e.Close(); err != nil {
203-
t.Fatal(err)
204-
}
205-
}
206-
207164
func TestEchoFile(t *testing.T) {
208165
e := New()
209166
e.File("/walle", "_fixture/images/walle.png")

group.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ func (g *Group) Use(middleware ...MiddlewareFunc) {
2323
if len(g.middleware) == 0 {
2424
return
2525
}
26+
// Allow all requests to reach the group as they might get dropped if router
27+
// doesn't find a match, making none of the group middleware process.
28+
g.Any("", NotFoundHandler)
29+
g.Any("/*", NotFoundHandler)
2630
}
2731

2832
// CONNECT implements `Echo#CONNECT()` for sub-routes within the Group.

group_test.go

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -119,37 +119,3 @@ func TestGroupRouteMiddlewareWithMatchAny(t *testing.T) {
119119
assert.Equal(t, "/*", m)
120120

121121
}
122-
123-
func TestMultipleGroupSamePathMiddleware(t *testing.T) {
124-
// Ensure multiple groups with the same path do not clobber previous routes or mixup middlewares
125-
e := New()
126-
m1 := func(next HandlerFunc) HandlerFunc {
127-
return func(c Context) error {
128-
c.Set("middleware", "m1")
129-
return next(c)
130-
}
131-
}
132-
m2 := func(next HandlerFunc) HandlerFunc {
133-
return func(c Context) error {
134-
c.Set("middleware", "m2")
135-
return next(c)
136-
}
137-
}
138-
h := func(c Context) error {
139-
return c.String(http.StatusOK, c.Get("middleware").(string))
140-
}
141-
142-
g1 := e.Group("/group", m1)
143-
{
144-
g1.GET("", h)
145-
}
146-
g2 := e.Group("/group", m2)
147-
{
148-
g2.GET("/other", h)
149-
}
150-
151-
_, m := request(http.MethodGet, "/group", e)
152-
assert.Equal(t, "m1", m)
153-
_, m = request(http.MethodGet, "/group/other", e)
154-
assert.Equal(t, "m2", m)
155-
}

0 commit comments

Comments
 (0)