summaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/routes.go
diff options
context:
space:
mode:
authorFrancis Lavoie <[email protected]>2021-09-17 02:52:32 -0400
committerGitHub <[email protected]>2021-09-17 00:52:32 -0600
commit907e2d8d3a8ebaf14aa99939c493e56645bc2089 (patch)
treef5aa4af53cdc9209075c6bc52e1aa0e12c7abc7b /modules/caddyhttp/routes.go
parent33c70f418f780f8e9524c73fbf4bbdbdbb9d7500 (diff)
downloadcaddy-907e2d8d3a8ebaf14aa99939c493e56645bc2089.tar.gz
caddy-907e2d8d3a8ebaf14aa99939c493e56645bc2089.zip
caddyhttp: Add support for triggering errors from `try_files` (#4346)
* caddyhttp: Add support for triggering errors from `try_files` * caddyhttp: Use vars instead of placeholders/replacer for matcher errors * caddyhttp: Add comment for matcher error var key
Diffstat (limited to 'modules/caddyhttp/routes.go')
-rw-r--r--modules/caddyhttp/routes.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/caddyhttp/routes.go b/modules/caddyhttp/routes.go
index ebd763c75..7b2871ff7 100644
--- a/modules/caddyhttp/routes.go
+++ b/modules/caddyhttp/routes.go
@@ -200,6 +200,15 @@ func wrapRoute(route Route) Middleware {
// route must match at least one of the matcher sets
if !route.MatcherSets.AnyMatch(req) {
+ // allow matchers the opportunity to short circuit
+ // the request and trigger the error handling chain
+ err, ok := GetVar(req.Context(), MatcherErrorVarKey).(error)
+ if ok {
+ return err
+ }
+
+ // call the next handler, and skip this one,
+ // since the matcher didn't match
return nextCopy.ServeHTTP(rw, req)
}