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

View File

@ -1743,3 +1743,15 @@ func TestContextStreamWithClientGone(t *testing.T) {
assert.Equal(t, "test", w.Body.String())
}
func TestContextResetInHandler(t *testing.T) {
w := CreateTestResponseRecorder()
c, _ := CreateTestContext(w)
c.handlers = []HandlerFunc{
func(c *Context) { c.reset() },
}
assert.NotPanics(t, func() {
c.Next()
})
}