mirror of
https://github.com/kataras/iris.git
synced 2025-03-21 11:16:28 +01:00
fix #1603
This commit is contained in:
parent
39e3911d41
commit
933534574a
|
@ -132,10 +132,18 @@ func overlapRoute(r *Route, next *Route) {
|
||||||
next.BuildHandlers()
|
next.BuildHandlers()
|
||||||
nextHandlers := next.Handlers[0:]
|
nextHandlers := next.Handlers[0:]
|
||||||
|
|
||||||
|
isErrorRoutes := r.StatusCode > 0 && next.StatusCode > 0
|
||||||
|
|
||||||
decisionHandler := func(ctx *context.Context) {
|
decisionHandler := func(ctx *context.Context) {
|
||||||
ctx.Next()
|
ctx.Next()
|
||||||
|
|
||||||
if !defaultOverlapFilter(ctx) {
|
if isErrorRoutes { // fixes issue #1602.
|
||||||
|
// If it's an error we don't need to reset (see defaultOverlapFilter)
|
||||||
|
// its status code(!) and its body, we just check if it was proceed or not.
|
||||||
|
if !ctx.IsStopped() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else if !defaultOverlapFilter(ctx) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,7 @@ func TestUseWrapOrder(t *testing.T) {
|
||||||
Iris Handler without any content written then we
|
Iris Handler without any content written then we
|
||||||
would able to change the status code later on.
|
would able to change the status code later on.
|
||||||
When you need to change that behavior you should
|
When you need to change that behavior you should
|
||||||
start the handler with a [ctx.Record()](responses/recorder.md) call.
|
start the handler with a ctx.Record() call.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,11 @@ var BuiltinDependencies = []*Dependency{
|
||||||
NewDependency(func(ctx *context.Context) *sessions.Session {
|
NewDependency(func(ctx *context.Context) *sessions.Session {
|
||||||
session := sessions.Get(ctx)
|
session := sessions.Get(ctx)
|
||||||
if session == nil {
|
if session == nil {
|
||||||
panic("binding: session is nil - app.Use(sess.Handler()) to fix it")
|
ctx.Application().Logger().Debugf("binding: session is nil\nMaybe inside HandleHTTPError? Register it with app.UseRouter(sess.Handler()) to fix it")
|
||||||
|
// let's don't panic here and let the application continue, now we support
|
||||||
|
// not matched routes inside the controller through HandleHTTPError,
|
||||||
|
// so each dependency can check if session was not nil or just use `UseRouter` instead of `Use`
|
||||||
|
// to register the sessions middleware.
|
||||||
}
|
}
|
||||||
|
|
||||||
return session
|
return session
|
||||||
|
|
Loading…
Reference in New Issue
Block a user