1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-19 10:57:05 +00:00

New: context#NextOr && context#NextOrNotFound and some performance improvements on the awesome https://github.com/kataras/iris/pull/909 pushed a while ago

Former-commit-id: 35dd2ab80b69a5bea6f35f58e636bc11229d9921
This commit is contained in:
Gerasimos Maropoulos
2018-02-23 04:06:05 +02:00
parent eeac8ccdbd
commit 6de64d517e
7 changed files with 70 additions and 34 deletions

View File

@@ -1,16 +1,12 @@
package router
import (
"net/http"
"github.com/kataras/iris/context"
)
import "github.com/kataras/iris/context"
// FallbackStack is a stack (with LIFO calling order) for fallback handlers
// A fallback handler(s) is(are) called from Fallback stack
// when no route found and before sending NotFound status.
// Therefore Handler(s) in Fallback stack could send another thing than NotFound status,
// if `Context.Next()` method is not called.
// if `context#NextOrNotFound()` method is not called.
// Done & DoneGlobal Handlers are not called.
type FallbackStack struct {
parent *FallbackStack
@@ -65,14 +61,5 @@ func (stk *FallbackStack) List() context.Handlers {
return res
}
// NewFallbackStack create a new Fallback stack with as first entry
// a handler which send NotFound status (the default)
func NewFallbackStack() *FallbackStack {
return &FallbackStack{
handlers: context.Handlers{
func(ctx context.Context) {
ctx.StatusCode(http.StatusNotFound)
},
},
}
}
// NewFallbackStack create a new empty Fallback stack.
func NewFallbackStack() *FallbackStack { return &FallbackStack{} }