rust-warp

Is there a way to do validation as part of a filter in Warp?

梦想与她 提交于 2021-02-07 14:30:31
问题 I have a route and an endpoint function defined. I've also injected some dependencies. pub fn route1() -> BoxedFilter<(String, ParamType)> { warp::get() .and(warp::path::param()) .and(warp::filters::query::query()) .and(warp::path::end()) .boxed() } pub async fn handler1( query: String, param: ParamType, dependency: DependencyType, ) -> Result<impl warp::Reply, warp::Rejection> { } let api = api::routes::route1() .and(warp::any().map(move || dependency)) .and_then(api::hanlders::hander1);