matchit icon indicating copy to clipboard operation
matchit copied to clipboard

Wildcard matching in the middle of the path

Open Bromles opened this issue 2 years ago • 4 comments

As discussed in Tokio's Discord server, it would be useful to add support for wildcard matching in the middle of the path

For instance, this is required to implement Docker Registry API V2 Some examples are provided below: /v2/<name>/ /v2/<name>/blobs/<digest> /v2/<name>/manifests/<reference> Note: <name> can contain any number of segments (at least 2), but is limited to 256 characters in length (including slashes)

Also, it can be useful for various git clients (something like /:repo/*filepath/action)

Bromles avatar Aug 08 '23 18:08 Bromles

Hello, Is this something still in discussion ? In my case we plan to migrate to Axum, right now we are using Actix. But this feature is mandatory for us in order to handle this case :

#[must_use]
pub fn imgsrv_scope<T: ServeSlide + 'static>() -> Scope {
    web::scope("/imgsrv")
        .route("{path:.+}/size", web::get().to(slide_size::<T>))
        .route("{path:.+}/roi", web::get().to(roi::<T>))
        .route("{path:.+}/slide", web::get().to(slide_info::<T>))
        .route("{path:.+}/tile", web::get().to(tile::<T>))
        .route("{path:.+}/thumbnail", web::get().to(thumbnail::<T>))
        .route("{path:.+}/is_compatible", web::get().to(is_compatible::<T>))
}

Thank you :)

AzHicham avatar Dec 02 '23 09:12 AzHicham

This should be easier to implement after the 0.8 syntax change and I think can be done without hurting performance in existing patterns.

ibraheemdev avatar Feb 05 '24 03:02 ibraheemdev

Now that 0.8 is release, I'll try to implement this along with https://github.com/ibraheemdev/matchit/issues/17. The implementation should be very similar.

ibraheemdev avatar Mar 10 '24 22:03 ibraheemdev