Closed outergod closed 3 years ago
Update, I was now able to write my own filter but it's not particularly pretty vs. what could be achieved if warp supported it directly.
fn method(name: &str) -> impl Filter<Extract = (), Error = Rejection> + Clone {
let method =
Method::from_str(name).expect(&format!("Method name {} could not be converted", name));
warp::method()
.and_then(move |m: Method| {
let method = method.clone();
async move {
if m == method {
Ok(())
} else {
Err(reject::custom(GatewayHandlerError::MethodNotAllowed))
}
}
})
.untuple_one()
}
Is your feature request related to a problem? Please describe. I'm trying to implement WebDAV handlers using warp, which requires filters for non-standard HTTP methods, as documented in RFC 4918. While
http::Method
allows defining custom methods, warp only provides a pre-defined set of filters for the standard methods and keepsmethod_is
infilters::method
private, so I couldn't figure out any other way to filter for custom methods.Describe the solution you'd like Making
method_is
public would probably be enough already. warp could provide some sugar forMethod::from_bytes
, but that is not absolutely necessary.Describe alternatives you've considered I could't figure out any other way to filter for the method in warp.
Additional context N/A