Skip to content

Fix routing for opaque nested services - #842

Merged
davidpdrsn merged 5 commits into
mainfrom
fix-opaque-nested-services
Mar 9, 2022
Merged

Fix routing for opaque nested services#842
davidpdrsn merged 5 commits into
mainfrom
fix-opaque-nested-services

Conversation

@davidpdrsn

@davidpdrsn davidpdrsn commented Mar 8, 2022

Copy link
Copy Markdown
Member

Fixes #830

This brings nesting of opaque services inline with nesting Routers, except for one case which is explained in a test. Also added a bunch more comments to the prefix stripping so I'll still be able to understanding it two days from now 😅

@davidpdrsn
davidpdrsn marked this pull request as ready for review March 8, 2022 22:06
@davidpdrsn
davidpdrsn requested a review from jplatte March 8, 2022 22:06
Comment thread axum/src/routing/mod.rs
let path = if path == "/" {
format!("/*{}", NEST_TAIL_PARAM)
let path = if path.ends_with('/') {
format!("{}*{}", path, NEST_TAIL_PARAM)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Before we would add a double slash to nest("/foo/", _).

uri = "/a",
prefix = "/",
expected = None,
expected = Some("/a"),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The outcome of this is the same. Not matching the prefix or matching and removing nothing from the path is equivalent.

uri = "/a/a",
prefix = "/a/",
expected = Some("/a"),
);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Case that wasn't handled properly before.

@davidpdrsn
davidpdrsn enabled auto-merge (squash) March 8, 2022 22:09
Comment thread axum/src/routing/tests/nest.rs Outdated
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
@davidpdrsn
davidpdrsn merged commit 401c7a3 into main Mar 9, 2022
@davidpdrsn
davidpdrsn deleted the fix-opaque-nested-services branch March 9, 2022 10:25
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.

Tests for truly nested routing?

2 participants