ibraheemdev / matchit

A high performance, zero-copy URL router.
https://docs.rs/matchit
MIT License
344 stars 35 forks source link

0.8.0 Feature List #35

Closed ibraheemdev closed 6 months ago

ibraheemdev commented 1 year ago
jplatte commented 1 year ago

I think I read a discussion about the new syntax before, this will include escaping { and } with {{ and }} just like in Rust's format! strings, right?

ibraheemdev commented 1 year ago

@jplatte yes. Catch-all routes will also be specified within the { } as /foo/{*wildcard}.

ibraheemdev commented 1 year ago

With {} parameters, we also run into more interesting conflicts. For example, given /{foo}.{bar} and /{foo}b{bar}, what does /ab.cd match? Both are /{ab}.{cd} and {a}b{.cd} are matches, but without a user-given priority the choice is unclear, so the routes should be considered conflicting.

There are two rules that I can see working for conflicts:

  1. Only allow a single specialized pattern per route segment. e.g. /{foo} and /{foo}.{bar} is fine, but adding /{foo}b{bar} causes a conflict.
  2. Allow multiple specialized patterns as long as they contain a different number of parameters. e.g. /{foo}, /{foo}.{bar}, /{foo}.{bar}.{baz} are fine, but adding /{foo}-{bar} causes a conflict. Specializations with a larger number of parameters take priority, e.g. /foo.bar.baz matches /{foo}.{bar}.{baz}, not /{foo}.{bar.baz}.

I'm leaning towards option 1 for simplicity's sake, and I'm not sure how much value option 2 would add.

jplatte commented 8 months ago

Hey @ibraheemdev, could you use any help with this? Looks like we'll want to ship axum 0.8 sooner rather than later (maybe around end of Q1'24, but that's entirely my personal guess) and it would be great to have the new matchit with different routing syntax included.

ibraheemdev commented 8 months ago

@jplatte Thanks for the reminder. I have most of the work finished locally, just need to clean some things up. It should be done by then, if not I'll try to have a 0.8 release with the new syntax that's still restricted to the old conflict rules to avoid delaying the inevitable breaking change further.

Totodore commented 6 months ago

Hey @ibraheemdev, #49 will be part of this version? Or do you plan to release it later? It is a feature that I would really need for my lib socketioxide. Thanks for your work :).

ibraheemdev commented 6 months ago

0.8 has been released! See the release notes for details.

@Totodore we can get #49 merged with a minor version bump now once it's ready that the major changes are out of the way.