Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

httpcaddyfile: Reorder some directives #4311

Merged
merged 1 commit into from
Aug 26, 2021
Merged

httpcaddyfile: Reorder some directives #4311

merged 1 commit into from
Aug 26, 2021

Conversation

francislavoie
Copy link
Member

@francislavoie francislavoie commented Aug 26, 2021

We realized we made some mistakes with the directive ordering, so we're making some minor adjustments.

abort and error 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 some file_server or respond typically. So we're moving them up to just before respond, 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 after handle/route, since its job is to read from response headers to push additional resources if necessary, and handle/route may be terminal so push would not be reached if it was declared outside those. And also, it would make sense to be before templates because a template could add a Link header to the response dynamically.

@francislavoie francislavoie added the under review 🧐 Review is pending before merging label Aug 26, 2021
@francislavoie francislavoie added this to the v2.4.4 milestone Aug 26, 2021
We realized we made some mistakes with the directive ordering, so we're making some minor adjustments.

`abort` and `error` 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 some `file_server` or `respond` typically. So we're moving them up to just before `respond`, 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

Also, `push` doesn't quite make sense to be after `handle`/`route`, since its job is to read from response headers to push additional resources if necessary, and `handle`/`route` may be terminal so push would not be reached if it was declared outside those. And also, it would make sense to be _before_ `templates` because a template _could_ add a `Link` header to the response dynamically.
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, these are good bug fixes. Might come as a surprise to a few users who relied on this buggy ordering, but this is more correct.

@mholt mholt merged commit 403732c into master Aug 26, 2021
@mholt mholt removed the under review 🧐 Review is pending before merging label Aug 26, 2021
@francislavoie francislavoie deleted the reorder-dirs branch August 26, 2021 20:49
@caddyserver caddyserver deleted a comment Aug 29, 2021
@caddyserver caddyserver deleted a comment Aug 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants