Struct actix_web::middleware::normalize::NormalizePath [−][src]
pub struct NormalizePath(_);
Expand description
Middleware
to normalize request’s URI in place
Performs following:
- Merges multiple slashes into one.
- Appends a trailing slash if one is not present, removes one if present, or keeps trailing
slashes as-is, depending on the supplied
TrailingSlash
variant.
use actix_web::{web, http, middleware, App, HttpResponse};
let app = App::new()
.wrap(middleware::NormalizePath::default())
.service(
web::resource("/test")
.route(web::get().to(|| HttpResponse::Ok()))
.route(web::method(http::Method::HEAD).to(|| HttpResponse::MethodNotAllowed()))
);
Implementations
Create new NormalizePath
middleware with the specified trailing slash style.
Trait Implementations
impl<S, B> Transform<S> for NormalizePath where
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
S::Future: 'static,
impl<S, B> Transform<S> for NormalizePath where
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
S::Future: 'static,
type Request = ServiceRequest
type Request = ServiceRequest
Requests handled by the service.
type Response = ServiceResponse<B>
type Response = ServiceResponse<B>
Responses given by the service.
type Transform = NormalizePathNormalization<S>
type Transform = NormalizePathNormalization<S>
The TransformService
value created by this factory
Creates and returns a new Transform component, asynchronously
fn map_init_err<F, E>(self, f: F) -> TransformMapInitErr<Self, S, F, E> where
F: Fn(Self::InitError) -> E + Clone,
fn map_init_err<F, E>(self, f: F) -> TransformMapInitErr<Self, S, F, E> where
F: Fn(Self::InitError) -> E + Clone,
Map this transforms’s factory error to a different error, returning a new transform service factory. Read more
Auto Trait Implementations
impl RefUnwindSafe for NormalizePath
impl Send for NormalizePath
impl Sync for NormalizePath
impl Unpin for NormalizePath
impl UnwindSafe for NormalizePath
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more