1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 18:07:01 +00:00
Former-commit-id: 6ac95ef58bf3dd0dac8bed2100495fa9908f41d4
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-02-10 20:35:19 +02:00
parent 10f280af63
commit c558e039d5
3 changed files with 28 additions and 3 deletions

View File

@@ -90,6 +90,7 @@ func NewConditionalHandler(filter Filter, handlers ...Handler) Handler {
// to check and modify the per-request handlers chain at runtime.
currIdx := ctx.HandlerIndex(-1)
currHandlers := ctx.Handlers()
if currIdx == len(currHandlers)-1 {
// if this is the last handler of the chain
// just add to the last the new handlers and call Next to fire those.
@@ -98,7 +99,7 @@ func NewConditionalHandler(filter Filter, handlers ...Handler) Handler {
return
}
// otherwise insert the new handlers in the middle of the current executed chain and the next chain.
newHandlers := append(currHandlers[:currIdx], append(handlers, currHandlers[currIdx+1:]...)...)
newHandlers := append(currHandlers[:currIdx+1], append(handlers, currHandlers[currIdx+1:]...)...)
ctx.SetHandlers(newHandlers)
ctx.Next()
return