httpcaddyfile: Reorder some directives #4311
Merged
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.
We realized we made some mistakes with the directive ordering, so we're making some minor adjustments.
abort
anderror
don't really make sense to be after other handler directives, because you would expect to be able to "fail-fast" and throw an error before falling through to somefile_server
orrespond
typically. So we're moving them up to just beforerespond
, i.e. before the common handler directives.This is also more consistent with our existing examples in the docs, which actually didn't work due to the directive ordering. See https://caddyserver.com/docs/caddyfile/directives/error#examples (added a test to prove that this example will work now, based on the
adapt
output)Also,
push
doesn't quite make sense to be afterhandle
/route
, since its job is to read from response headers to push additional resources if necessary, andhandle
/route
may be terminal so push would not be reached if it was declared outside those. And also, it would make sense to be beforetemplates
because a template could add aLink
header to the response dynamically.