summaryrefslogtreecommitdiff
path: root/modules/caddyhttp
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2021-05-05 17:55:40 -0400
committerGitHub <noreply@github.com>2021-05-05 15:55:40 -0600
commitd4b2f1bcee2190d13bc96aa8da5ea530bd6b9a22 (patch)
tree0c95c63c548ea9aae5b89961a7dae9e58c94767d /modules/caddyhttp
parenta17c3b568d635ea45deb204d06e251810e94a7d6 (diff)
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 95b6ac44a6122d3ca5513a13bbc723cd5f4785f8. * caddyhttp: Fix via `routes.go`
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r--modules/caddyhttp/routes.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/caddyhttp/routes.go b/modules/caddyhttp/routes.go
index 83e6354..ebd763c 100644
--- a/modules/caddyhttp/routes.go
+++ b/modules/caddyhttp/routes.go
@@ -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