Warp: Altering request URL before other filter consumes it ("URL rewrite")

Hi,

I'd like to serve static files with warp::fs::dir.

If a page without a file extension is requested, I'd like to add a default extension.

For example, if a visitor requests "/foo", and my default extension is "html", the requested URL becomes "/foo.html", and warp::fs::dir would look for "foo.html" in the static file directory.

Is this somehow possible? I can't find a way to do it.

What I try to archive:

let route = warp::path("static")
    // somehow change the URL here
    .and(warp::fs::dir("/www/static"));

This is not possible to archive directly with warp.

The maintainer of the crate wrote to me on the warp discord channel:

Not with warp directly. You could make a tower::Service layer that wraps the filters