-
Notifications
You must be signed in to change notification settings - Fork 218
Closed
Description
Hi!
I took the example ValidateRequest impl from https://docs.rs/tower-http/latest/tower_http/validate_request/index.html but when using it with Axum it fails while the provided implementations work out of the box.
error[E0271]: type mismatch resolving `<Route as Service<Request<Body>>>::Response == Response<Body>`
--> simple-rest/src/main.rs:92:16
|
92 | .layer(ValidateRequestHeaderLayer::custom(MyHeader {}))
| ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Body`, found struct `UnsyncBoxBody`
| |
| required by a bound introduced by this calllet app = Router::new()
.layer(ValidateRequestHeaderLayer::custom(MyHeader {})) use tower_http::validate_request::{ValidateRequestHeaderLayer, ValidateRequest};
use hyper::{Request, Response, Body, Error};
use http::{StatusCode, header::ACCEPT};
use tower::{Service, ServiceExt, ServiceBuilder, service_fn};
#[derive(Clone, Copy)]
pub struct MyHeader { /* ... */ }
impl<B> ValidateRequest<B> for MyHeader {
type ResponseBody = Body;
fn validate(
&mut self,
request: &mut Request<B>,
) -> Result<(), Response<Self::ResponseBody>> {
// validate the request...
Ok(())
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels