docs: Add error caddyfile directive#143
Merged
mholt merged 1 commit intocaddyserver:masterfrom Apr 16, 2021
francislavoie:error-directive
Merged
docs: Add error caddyfile directive#143mholt merged 1 commit intocaddyserver:masterfrom francislavoie:error-directive
error caddyfile directive#143mholt merged 1 commit intocaddyserver:masterfrom
francislavoie:error-directive
Conversation
Docs for the new directive in caddyserver/caddy#4034. Also adding a bit in `handle_errors` mentioning that `reverse_proxy` doesn't trigger errors when a response has an "error" HTTP status; not sure how to word this clearly, cause `reverse_proxy` still can trigger errors if there's no upstream or whatever. We should probably add examples for that later, and augment this paragraph to mention `handle_response` once that's merged (caddyserver/caddy#4021)
francislavoie
commented
Mar 14, 2021
| When the normal HTTP request handlers return an error, normal processing stops and the error handlers are invoked. Error handlers form a route which is just like normal routes, and they can do anything that normal routes can do. This enables great control and flexibility when handling errors during HTTP requests. For example, you can serve static error pages, templated error pages, or reverse proxy to another backend to handle errors. | ||
|
|
||
| A request's context is carried into error routes, so any values set on the request context such as [site root](/docs/caddyfile/directives/root) will be preserved in error handlers, too. Additionally, new placeholders are available when handling errors. [The JSON docs for an HTTP server's error routes](/docs/json/apps/http/servers/errors/#routes) describe these placeholders. The `handle_errors` directive simply adds error routes, so you can use those placeholders within a `handle_errors` block. | ||
| A request's context is carried into error routes, so any values set on the request context such as [site root](root) will be preserved in error handlers, too. Additionally, new placeholders are available when handling errors. [The JSON docs for an HTTP server's error routes](/docs/json/apps/http/servers/errors/#routes) describe these placeholders. The `handle_errors` directive simply adds error routes, so you can use those placeholders within a `handle_errors` block. |
Member
Author
There was a problem hiding this comment.
The only change on this line is shortening the link in [site root](root), github doesn't make that obvious
mholt
approved these changes
Apr 16, 2021
Member
mholt
left a comment
There was a problem hiding this comment.
Looks good, thanks as usual! Really appreciate all your help with the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Docs for the new directive in caddyserver/caddy#4034.
Also adding a bit in
handle_errorsmentioning thatreverse_proxydoesn't trigger errors when a response has an "error" HTTP status; not sure how to word this clearly, causereverse_proxystill can trigger errors if there's no upstream or whatever. We should probably add examples for that later, and augment this paragraph to mentionhandle_responseonce that's merged (caddyserver/caddy#4021)