fix Context.Next() - recheck len of handlers every iteration (#1745)

* fix Context.Next() - recheck len of handlers every iteration

* add tests when Context.reset() can be called inside of handler

TestEngineHandleContext
TestContextResetInHandler
TestRouterStaticFSFileNotFound

* Context.Next() - format to while style
This commit is contained in:
Dmitry Kutakov
2019-01-18 04:57:06 +03:00
committed by thinkerou
parent b056a34bdc
commit 4867ff9634
4 changed files with 41 additions and 1 deletions
+17
View File
@@ -471,6 +471,23 @@ func TestListOfRoutes(t *testing.T) {
})
}
func TestEngineHandleContext(t *testing.T) {
r := New()
r.GET("/", func(c *Context) {
c.Request.URL.Path = "/v2"
r.HandleContext(c)
})
v2 := r.Group("/v2")
{
v2.GET("/", func(c *Context) {})
}
assert.NotPanics(t, func() {
w := performRequest(r, "GET", "/")
assert.Equal(t, 301, w.Code)
})
}
func assertRoutePresent(t *testing.T, gotRoutes RoutesInfo, wantRoute RouteInfo) {
for _, gotRoute := range gotRoutes {
if gotRoute.Path == wantRoute.Path && gotRoute.Method == wantRoute.Method {