| 124 | } |
| 125 | |
| 126 | func TestGroupRouteMiddlewareWithMatchAny(t *testing.T) { |
| 127 | // Ensure middleware and match any routes do not conflict |
| 128 | e := New() |
| 129 | g := e.Group("/group") |
| 130 | m1 := func(next HandlerFunc) HandlerFunc { |
| 131 | return func(c *Context) error { |
| 132 | return next(c) |
| 133 | } |
| 134 | } |
| 135 | m2 := func(next HandlerFunc) HandlerFunc { |
| 136 | return func(c *Context) error { |
| 137 | return c.String(http.StatusOK, c.RouteInfo().Path) |
| 138 | } |
| 139 | } |
| 140 | h := func(c *Context) error { |
| 141 | return c.String(http.StatusOK, c.RouteInfo().Path) |
| 142 | } |
| 143 | g.Use(m1) |
| 144 | g.GET("/help", h, m2) |
| 145 | g.GET("/*", h, m2) |
| 146 | g.GET("", h, m2) |
| 147 | e.GET("unrelated", h, m2) |
| 148 | e.GET("*", h, m2) |
| 149 | |
| 150 | _, m := request(http.MethodGet, "/group/help", e) |
| 151 | assert.Equal(t, "/group/help", m) |
| 152 | _, m = request(http.MethodGet, "/group/help/other", e) |
| 153 | assert.Equal(t, "/group/*", m) |
| 154 | _, m = request(http.MethodGet, "/group/404", e) |
| 155 | assert.Equal(t, "/group/*", m) |
| 156 | _, m = request(http.MethodGet, "/group", e) |
| 157 | assert.Equal(t, "/group", m) |
| 158 | _, m = request(http.MethodGet, "/other", e) |
| 159 | assert.Equal(t, "/*", m) |
| 160 | _, m = request(http.MethodGet, "/", e) |
| 161 | assert.Equal(t, "/*", m) |
| 162 | |
| 163 | } |
| 164 | |
| 165 | func TestGroup_CONNECT(t *testing.T) { |
| 166 | e := New() |