Split routes by verb during compilation#6739
Open
josevalim wants to merge 3 commits into
Open
Conversation
Member
|
I think it's fine to just mention it in the changelog. Alternatively, maybe we could detect such dead routes at compile time and drop them to keep the same behavior, emitting a deprecation warning? Then we drop that extra code for 2.0. |
This pull request compiles routes by verb, which speeds up
compilation times for large routes. This is done by making
sure `match/forward` statements always come last.
Therefore, this pull request changes the semantics of *dead
routes*. If you had this code:
match "/foo"
get "/foo"
The second route would never be matched but it is now as part
of this pull request. However, `get "/foo"` should not be there
in the first place. So the routes should either be rearranged
or removed anyway.
a8bfabf to
a2abbbb
Compare
SteffenDE
reviewed
Jun 29, 2026
| match :*, "/foo" | ||
| get "/foo" | ||
|
|
||
| The second route would never be matched but it will now be as part of this pull request. However, note that `get "/foo"` should not exist in the first place: it should be either removed or moved first. We recommend checking for any `match :*` in your router and moving them to the end of the file. |
Member
There was a problem hiding this comment.
Suggested change
| The second route would never be matched but it will now be as part of this pull request. However, note that `get "/foo"` should not exist in the first place: it should be either removed or moved first. We recommend checking for any `match :*` in your router and moving them to the end of the file. | |
| The second route would never be matched but it will now be as part of this change. However, note that `get "/foo"` should not exist in the first place: it should be either removed or moved first. We recommend checking for any `match :*` in your router and moving them to the end of the file. |
| assert conn.resp_body == "users move" | ||
| end | ||
|
|
||
| test "any verb matches" do |
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.
This pull request groups compiled routes by verb, which speeds up compilation times for large routers up to 3x. A side-effect is that
match/forwardroutes are always matched last.Therefore, this pull request changes the semantics of dead routes. If you had this code:
The second route would never be matched but it is now as part of this pull request. However,
get "/foo"should not be there in the first place. It is effectively a dead route.Currently WIP. We should either document this pitfall or put this change behind an option. I am fine with documenting this in the CHANGELOG as the code above should either not exist or be correct anyway.