Skip to content

Comments

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

Draft
mladedav wants to merge 1 commit intomainfrom
dm/matchit-8-6
Draft

axum: Update matchit to 0.8.6 and support capture prefixes and suffixes#3143
mladedav wants to merge 1 commit intomainfrom
dm/matchit-8-6

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 matchit@0.9.0 because of ambiguities between prefix{capture} and {capture}suffix. See the linked issue for details.

@puppymati
Copy link

puppymati commented Nov 1, 2025

bumping this since matchit 0.9.0 has been released and I am currently depending on a private fork to use it. Would be nice to see it implemented :)

@ADD-SP
Copy link
Member

ADD-SP commented Feb 19, 2026

Hi, @mladedav, any update on this PR? May I take over this task if you are not working on it. I also need the newer version of matchit.

@mladedav
Copy link
Collaborator Author

Sure go for it, I forgot to come back to this after the 0.9 matchit release.

I think it should work the same way so it should be pretty straightforward to finish this.

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

4 participants