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

axum: Update matchit to 0.8.6 and support capture prefixes and suffixes #3143

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mladedav
Copy link
Collaborator

@mladedav mladedav commented Jan 3, 2025

Motivation

Closes #3140

matchit released a new version which now supports prefixes and suffixes in routes like \{image}.png.

Solution

This updates the dependency and makes sure the stripping works properly with the new routes.

Open Questions

  • We have locked matchit version to 0.8.0 (and then later to 0.8.4) because changes like these could introduce problems such as that it would be legal to register paths using new matchit features but axum would be broken because it wouldn't know how to work with it. We can continue in the same spirit, locking the version to 0.8.6 or we can relax the requirement to not require the same version. I suspect e.g. this issue could have similar effects.
  • The fact that \foo does not match \foo{capture} might be surprising to users. I've added it to docs about captures but I feel it can be easily overlooked. It is consistent with normal captures which must not be empty either. We could automatically register \foo along with \foo{capture} but I'm not sure about that.
  • nest and nest_service will be subtly different. In short nest should be preferred as it will take into consideration the whole path while nest_service will decide which service to call just based on the prefix. More details can be found here. We might consider not allowing partial captures in nest_service prefixes. I wouldn't expect people to run into this but if someone does, the difference might be very surprising.
  • Naming of Path can be confusing when using e.g. \{file}.png as the Path<String> extractor will contain only the capture. I don't think we want to change this but I wanted to flag it if anyone thinks we should.

@mladedav mladedav marked this pull request as draft January 3, 2025 21:41
@mladedav
Copy link
Collaborator Author

mladedav commented Jan 3, 2025

I've turned this into a draft because we might wait for [email protected] because of ambiguities between prefix{capture} and {capture}suffix. See the linked issue for details.

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.

Update matchit to 0.8.6
2 participants