workers-rs icon indicating copy to clipboard operation
workers-rs copied to clipboard

Update matchit to version 0.4.5.

Open asgpng opened this issue 3 years ago • 3 comments

matchit v0.4.4 adds support for fallback routes with overlapping patterns, as specified in https://github.com/ibraheemdev/matchit/issues/4.

This PR updates the dependency version used in worker to 0.4.4.

I've tested this on a personal cloudflare worker site and am getting expected behavior. Let me know if there's any specific testing or things I'm missing from this PR. Thanks!

asgpng avatar Dec 18 '21 16:12 asgpng

Hi @asgpng -

Thanks for this! Looks like we could probably re-implement the routing to take advantage of this fallback feature instead of the workarounds we have currently. I'll probably hold off on merging this until after the holidays, when I can spend enough time considering the impacts.

If you are interested, take a look at the Router implementation in workers-rs and lmk if you see anywhere specific that the updates in matchit could benefit us. No pressure though, thanks again for bringing this to my attention!

nilslice avatar Dec 22 '21 20:12 nilslice

Hi @nilslice - thanks for the response! Circling back after the holidays sounds great.

Looks like we could probably re-implement the routing to take advantage of this fallback feature instead of the workarounds we have currently.

By 'workarounds', are you referring to the or_else_any_method_handler? That could be a pretty reasonable build, as it would reduce the surface area of the Router API while still providing all the existing functionality.

E.g., instead of:

Router::new()
    .post_async("/foo/specific", ...)
    .or_else_any_method("/foo/:other", ...)

you could do:

Router::new()
    .post_async("/foo/specific", ...)
    .post_async("/foo/:other", ...)

If we feel this the direction to go, I'd be happy to augment the PR with removal of the or_else_any logic, which seems redundant and would probably be confusing to users if offered as part of the API in addition to the native matchit behavior.

asgpng avatar Dec 23 '21 14:12 asgpng

Yes, exactly! If you want to, please go ahead. Feel free to ping here with any questions / issues if you run into any.

nilslice avatar Dec 23 '21 15:12 nilslice

Superseded by #450

kflansburg avatar Mar 15 '24 15:03 kflansburg