I would like to handle these cases in Actix:
/foo
/foo/
/foo/.*
(anything including slashes)
Note that foo
is a constant string, and I do not need to actually parse the path. Instead, in my handler I will
pub async fn on_foo(
client: web::Data<reqwest::Client>,
req: HttpRequest,
mut payload: web::Payload,
) -> Result<HttpResponse, Error> {
...
// Use client to fully forward any /foo... requests elsewhere
// using req.path() to get the full original path.
}
It seems one option is to use scopes:
.service(
actix_web::web::scope("/foo").default_service(actix_web::web::to(on_foo))
),
But this method doesn't seem to handle /foo/
(while it does look like it handles the other two cases)