Closed samueljoli closed 11 months ago
The Building a middleware from scratch is a great guide, I think it would be an improvement if the following steps were added:
impl TimeoutLayer { /// Create a timeout from a duration pub fn new(timeout: Duration) -> Self { TimeoutLayer { timeout } } }
impl Layer for TimeoutLayer { type Service = Timeout;
fn layer(&self, service: S) -> Self::Service { Timeout::new(service, self.timeout) }
}
- [Error handling for middleware](https://docs.rs/axum/latest/axum/middleware/index.html#error-handling-for-middleware) - Using the layer (integration with `ServiceBuilder`
The Building a middleware from scratch is a great guide, I think it would be an improvement if the following steps were added:
impl
Layerfor TimeoutLayer { type Service = Timeout;}