Skip to content

Commit

Permalink
fix context bug, if something wrote to http, break handle chain
Browse files Browse the repository at this point in the history
  • Loading branch information
coldstar committed Apr 22, 2016
1 parent 53c1526 commit 070d3eb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions context.go
Expand Up @@ -561,10 +561,17 @@ func (c *Context) parseForm() {

// Next execute next handler
// handle middleware first, last execute route handler
// if something wrote to http, break chain and return
func (c *Context) Next() {
if c.hi >= len(c.handlers) {
return
}
if c.Resp.Wrote() {
if c.baa.Debug() {
c.baa.Logger().Println("Warning: content has been written, handle chain break.")
}
return
}
i := c.hi
c.hi++
c.handlers[i](c)
Expand Down

0 comments on commit 070d3eb

Please sign in to comment.