mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 06:03:48 +03:00
caddyhttp: Fix fallback for the error handler chain (#4131)
* caddyhttp: Fix fallback for the error handler chain
The fix I went with in the end (after realizing some mistaken assumptions in #4131) is to just make the routes fall back to errorEmptyHandler instead of the non-error empty handler, if Terminal is true, making the routes error-aware. Ultimately this was probably just an oversight when errors was implemented at some point in the early betas of v2.
See https://caddy.community/t/problem-with-basicauth-handle-errors/12243/9 for context.
* Revert "caddyhttp: Fix fallback for the error handler chain"
This reverts commit 95b6ac44a6
.
* caddyhttp: Fix via `routes.go`
This commit is contained in:
parent
a17c3b568d
commit
d4b2f1bcee
1 changed files with 5 additions and 1 deletions
|
@ -220,7 +220,11 @@ func wrapRoute(route Route) Middleware {
|
|||
|
||||
// make terminal routes terminate
|
||||
if route.Terminal {
|
||||
nextCopy = emptyHandler
|
||||
if _, ok := req.Context().Value(ErrorCtxKey).(error); ok {
|
||||
nextCopy = errorEmptyHandler
|
||||
} else {
|
||||
nextCopy = emptyHandler
|
||||
}
|
||||
}
|
||||
|
||||
// compile this route's handler stack
|
||||
|
|
Loading…
Reference in a new issue