# Struct actix_web::http::NormalizePath[−][src]

    pub struct NormalizePath { /* fields omitted */ }

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]

####

`pub fn new(append: bool, merge: bool, redirect: StatusCode) -> NormalizePath`

[src]

Create new `NormalizePath` instance

## Trait Implementations

###

`impl Default for NormalizePath`

[src]

####

`fn default() -> NormalizePath`

[src]

Create default `NormalizePath` instance, append is set to true, merge is set to true and redirect is set to `StatusCode::MOVED_PERMANENTLY`

###

`impl<S> Handler<S> for NormalizePath`

[src]

#### `type Result = HttpResponse`

The type of value that handler will return.

####

`fn handle(&self, req: &HttpRequest<S>) -> Self::Result`

[src]

Handle request

## Auto Trait Implementations

###

`impl Send for NormalizePath`

###

`impl Sync for NormalizePath`

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)