[−][src]Struct actix_web::http::NormalizePath
Path normalization helper
By normalizing it means:
- Add a trailing slash to the path.
- Remove a trailing slash from the path.
- Double slashes are replaced by one.
The handler returns as soon as it finds a path that resolves correctly. The order if all enable is 1) merge, 3) both merge and append and 3) append. If the path resolves with at least one of those conditions, it will redirect to the new path.
If append is true append slash when needed. If a resource is defined with trailing slash and the request comes without it, it will append it automatically.
If merge is true, merge multiple consecutive slashes in the path into one.
This handler designed to be use as a handler for application's default resource.
use actix_web::http::NormalizePath; fn main() { let app = App::new() .resource("/test/", |r| r.f(index)) .default_resource(|r| r.h(NormalizePath::default())) .finish(); }
In this example /test
, /test///
will be redirected to /test/
url.
Methods
impl NormalizePath
[src]
impl NormalizePath
pub fn new(append: bool, merge: bool, redirect: StatusCode) -> NormalizePath
[src]
pub fn new(append: bool, merge: bool, redirect: StatusCode) -> NormalizePath
Create new NormalizePath
instance
Trait Implementations
impl<S> Handler<S> for NormalizePath
[src]
impl<S> Handler<S> for NormalizePath
type Result = HttpResponse
The type of value that handler will return.
fn handle(&self, req: &HttpRequest<S>) -> Self::Result
[src]
fn handle(&self, req: &HttpRequest<S>) -> Self::Result
Handle request
impl Default for NormalizePath
[src]
impl Default for NormalizePath
fn default() -> NormalizePath
[src]
fn default() -> NormalizePath
Create default NormalizePath
instance, append is set to true,
merge is set to true and redirect is set to
StatusCode::MOVED_PERMANENTLY
Auto Trait Implementations
impl Send for NormalizePath
impl Send for NormalizePath
impl Sync for NormalizePath
impl Sync for NormalizePath
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> Erased for T
impl<T> Erased for T