diff options
author | Matt Holt <[email protected]> | 2021-01-28 12:54:55 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2021-01-28 12:54:55 -0700 |
commit | e2c5c28597e6a8c5e7ef48fde88f0b7d740d9586 (patch) | |
tree | 5182a73cc3aadd452b1eadce4370a05985c75c91 /caddyconfig | |
parent | ab80ff4fd2911afc394b9dbceeb9f71c7a0b7ec1 (diff) | |
download | caddy-e2c5c28597e6a8c5e7ef48fde88f0b7d740d9586.tar.gz caddy-e2c5c28597e6a8c5e7ef48fde88f0b7d740d9586.zip |
caddyhttp: Implement handler abort; new 'abort' directive (close #3871) (#3983)
* caddyhttp: Implement handler abort; new 'abort' directive (close #3871)
* Move abort directive ordering; clean up redirects
Seems logical for the end-all of handlers to go at the... end.
The Connection header no longer needs to be set there, since Close is
true, and the static_response handler now does that.
Diffstat (limited to 'caddyconfig')
-rw-r--r-- | caddyconfig/httpcaddyfile/builtins.go | 10 | ||||
-rw-r--r-- | caddyconfig/httpcaddyfile/directives.go | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/caddyconfig/httpcaddyfile/builtins.go b/caddyconfig/httpcaddyfile/builtins.go index 08dfa886a..2de808b92 100644 --- a/caddyconfig/httpcaddyfile/builtins.go +++ b/caddyconfig/httpcaddyfile/builtins.go @@ -40,6 +40,7 @@ func init() { RegisterHandlerDirective("root", parseRoot) RegisterHandlerDirective("redir", parseRedir) RegisterHandlerDirective("respond", parseRespond) + RegisterHandlerDirective("abort", parseAbort) RegisterHandlerDirective("route", parseRoute) RegisterHandlerDirective("handle", parseHandle) RegisterDirective("handle_errors", parseHandleErrors) @@ -502,6 +503,15 @@ func parseRespond(h Helper) (caddyhttp.MiddlewareHandler, error) { return sr, nil } +// parseAbort parses the abort directive. +func parseAbort(h Helper) (caddyhttp.MiddlewareHandler, error) { + h.Next() // consume directive + for h.Next() || h.NextBlock(0) { + return nil, h.ArgErr() + } + return &caddyhttp.StaticResponse{Abort: true}, nil +} + // parseRoute parses the route directive. func parseRoute(h Helper) (caddyhttp.MiddlewareHandler, error) { sr := new(caddyhttp.Subroute) diff --git a/caddyconfig/httpcaddyfile/directives.go b/caddyconfig/httpcaddyfile/directives.go index b79b81165..7f77f49f2 100644 --- a/caddyconfig/httpcaddyfile/directives.go +++ b/caddyconfig/httpcaddyfile/directives.go @@ -69,6 +69,7 @@ var directiveOrder = []string{ "php_fastcgi", "file_server", "acme_server", + "abort", } // directiveIsOrdered returns true if dir is |