summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/routes.go
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2021-09-17 02:52:32 -0400
committerGitHub <noreply@github.com>2021-09-17 00:52:32 -0600
commit907e2d8d3a8ebaf14aa99939c493e56645bc2089 (patch)
treef5aa4af53cdc9209075c6bc52e1aa0e12c7abc7b /modules/caddyhttp/routes.go
parent33c70f418f780f8e9524c73fbf4bbdbdbb9d7500 (diff)
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 ebd763c..7b2871f 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)
}