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

Panic on overlapping routes in MethodRouter #1102

Merged
merged 3 commits into from Jun 18, 2022

Conversation

davidpdrsn
Copy link
Member

Makes get(foo).get(bar) panic, similarly to Router::route.

Fixes #1097

Copy link
Member

@jplatte jplatte left a comment

Choose a reason for hiding this comment

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

What about get(foo).head(bar)? We probably want that to work, no?

@davidpdrsn
Copy link
Member Author

It does work already but I added tests just to make sure. It works because we only override the corresponding service so doing get(foo) doesn't set the head service. Instead we call get for both GET and HEAD requests here https://github.com/tokio-rs/axum/blob/main/axum/src/routing/method_routing.rs#L1079-L1080.

@davidpdrsn davidpdrsn merged commit f9de42e into axum-next Jun 18, 2022
@davidpdrsn davidpdrsn deleted the method-routing-detect-overlaps branch June 18, 2022 09:19
davidpdrsn added a commit that referenced this pull request Jun 25, 2022
* Panic on overlapping routes in `MethodRouter`

* changelog link

* add test to ensure `head` and `get` don't overlap
davidpdrsn added a commit that referenced this pull request Jun 25, 2022
* Panic on overlapping routes in `MethodRouter`

* changelog link

* add test to ensure `head` and `get` don't overlap
davidpdrsn added a commit that referenced this pull request Jun 27, 2022
* Panic on overlapping routes in `MethodRouter`

* changelog link

* add test to ensure `head` and `get` don't overlap
davidpdrsn added a commit that referenced this pull request Jun 28, 2022
* Panic on overlapping routes in `MethodRouter`

* changelog link

* add test to ensure `head` and `get` don't overlap
davidpdrsn added a commit that referenced this pull request Jun 28, 2022
* Panic on overlapping routes in `MethodRouter`

* changelog link

* add test to ensure `head` and `get` don't overlap
davidpdrsn added a commit that referenced this pull request Jun 29, 2022
* Prepare axum-next branch

* Remove deprecated `extractor_middleware` function (#1077)

* Allow `Error: Into<Infallible>` for `Route::{layer, route_layer}` (#948)

* Allow `Error: Into<Infallible>` for `Route::{layer, route_layer}` (#924)

* Allow `Error: Into<Infallible>` for `Route::{layer, route_layer}`

Fixes #922

* changelog

* fixup changelog

* Panic on overlapping routes in `MethodRouter` (#1102)

* Panic on overlapping routes in `MethodRouter`

* changelog link

* add test to ensure `head` and `get` don't overlap

* Fix changelog

* Prepare axum-next branch

* Remove trailing slash redirects

* changelog link

* Fix changelog

* remove asserting to make make the test more clear

* remove tsr related feature

* Add `RouterExt::route_with_tsr`

* Apply suggestions from code review

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>

* Update axum-extra/src/routing/mod.rs

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>

* fix typos in docs

* Update axum/CHANGELOG.md

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>

* mention `RouterExt::route_with_tsr` in the changelog

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants