diff --git a/src/middleware/normalize.rs b/src/middleware/normalize.rs index 7289e8d97..a92ba5ade 100644 --- a/src/middleware/normalize.rs +++ b/src/middleware/normalize.rs @@ -13,14 +13,30 @@ use crate::Error; /// Performs following: /// /// - Merges multiple slashes into one. +/// +/// ```rust +/// use actix_web::{web, http, middleware, App, HttpResponse}; +/// +/// fn main() { +/// let app = App::new() +/// .wrap(middleware::NormalizePath) +/// .service( +/// web::resource("/test") +/// .route(web::get().to(|| HttpResponse::Ok())) +/// .route(web::method(http::Method::HEAD).to(|| HttpResponse::MethodNotAllowed())) +/// ); +/// } +/// ``` + pub struct NormalizePath; -impl Transform for NormalizePath +impl Transform for NormalizePath where - S: Service, + S: Service, Error = Error>, + S::Future: 'static, { type Request = ServiceRequest; - type Response = ServiceResponse; + type Response = ServiceResponse; type Error = Error; type InitError = (); type Transform = NormalizePathNormalization; @@ -39,12 +55,13 @@ pub struct NormalizePathNormalization { merge_slash: Regex, } -impl Service for NormalizePathNormalization +impl Service for NormalizePathNormalization where - S: Service, + S: Service, Error = Error>, + S::Future: 'static, { type Request = ServiceRequest; - type Response = ServiceResponse; + type Response = ServiceResponse; type Error = Error; type Future = S::Future;