mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 18:07:01 +00:00
new feature: versioned controllers
Former-commit-id: c797e23c78b1e74bbe9ba56673f3a98f17f5e2f7
This commit is contained in:
@@ -283,3 +283,24 @@ func NewConditionalHandler(filter Filter, handlers ...Handler) Handler {
|
||||
ctx.Next()
|
||||
}
|
||||
}
|
||||
|
||||
// JoinHandlers returns a copy of "h1" and "h2" Handlers slice joined as one slice of Handlers.
|
||||
func JoinHandlers(h1 Handlers, h2 Handlers) Handlers {
|
||||
if len(h1) == 0 {
|
||||
return h2
|
||||
}
|
||||
|
||||
if len(h2) == 0 {
|
||||
return h1
|
||||
}
|
||||
|
||||
nowLen := len(h1)
|
||||
totalLen := nowLen + len(h2)
|
||||
// create a new slice of Handlers in order to merge the "h1" and "h2"
|
||||
newHandlers := make(Handlers, totalLen)
|
||||
// copy the already Handlers to the just created
|
||||
copy(newHandlers, h1)
|
||||
// start from there we finish, and store the new Handlers too
|
||||
copy(newHandlers[nowLen:], h2)
|
||||
return newHandlers
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user