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

@ -105,8 +105,9 @@ func (c *Context) Handler() HandlerFunc {
// See example in GitHub.
func (c *Context) Next() {
c.index++
for s := int8(len(c.handlers)); c.index < s; c.index++ {
for c.index < int8(len(c.handlers)) {
c.handlers[c.index](c)
c.index++
}
}