summaryrefslogtreecommitdiff
path: root/caddyconfig/httpcaddyfile
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2022-09-15 12:05:36 -0400
committerGitHub <noreply@github.com>2022-09-15 10:05:36 -0600
commit9ad0ebc956f4317111c12e2c5428acd18522f025 (patch)
tree8745311ffa02013876d90e3b45715b6a6316e7e9 /caddyconfig/httpcaddyfile
parenta1ad20e4720391d847c58fcdcef7c8d9c287faf2 (diff)
caddyhttp: Add 'skip_log' var to omit request from logs (#4691)
* caddyhttp: Implement `skip_log` handler * Refactor to use vars middleware Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
Diffstat (limited to 'caddyconfig/httpcaddyfile')
-rw-r--r--caddyconfig/httpcaddyfile/builtins.go13
-rw-r--r--caddyconfig/httpcaddyfile/directives.go1
2 files changed, 14 insertions, 0 deletions
diff --git a/caddyconfig/httpcaddyfile/builtins.go b/caddyconfig/httpcaddyfile/builtins.go
index cd23348..103b7a1 100644
--- a/caddyconfig/httpcaddyfile/builtins.go
+++ b/caddyconfig/httpcaddyfile/builtins.go
@@ -48,6 +48,7 @@ func init() {
RegisterHandlerDirective("handle", parseHandle)
RegisterDirective("handle_errors", parseHandleErrors)
RegisterDirective("log", parseLog)
+ RegisterHandlerDirective("skip_log", parseSkipLog)
}
// parseBind parses the bind directive. Syntax:
@@ -858,3 +859,15 @@ func parseLogHelper(h Helper, globalLogNames map[string]struct{}) ([]ConfigValue
}
return configValues, nil
}
+
+// parseSkipLog parses the skip_log directive. Syntax:
+//
+// skip_log [<matcher>]
+func parseSkipLog(h Helper) (caddyhttp.MiddlewareHandler, error) {
+ for h.Next() {
+ if h.NextArg() {
+ return nil, h.ArgErr()
+ }
+ }
+ return caddyhttp.VarsMiddleware{"skip_log": true}, nil
+}
diff --git a/caddyconfig/httpcaddyfile/directives.go b/caddyconfig/httpcaddyfile/directives.go
index e2113eb..5ab092d 100644
--- a/caddyconfig/httpcaddyfile/directives.go
+++ b/caddyconfig/httpcaddyfile/directives.go
@@ -42,6 +42,7 @@ var directiveOrder = []string{
"map",
"vars",
"root",
+ "skip_log",
"header",
"copy_response_headers", // only in reverse_proxy's handle_response