#actix-middleware #middleware #actix #clean #redirect #uri #necessary

actix-clean-path

Middleware to clean request's URI, and redirect if necessary

1 stable release

1.0.0 Jun 29, 2020

#20 in #actix-middleware

MIT license

9KB
150 lines

actix-clean-path

Build Crates.io Documentation

Middleware to clean request's URI, and redirect if necessary. See documentation for how to use the library.


lib.rs:

Middleware to clean request's URI, and redirect if necessary.

Performs following:

  • Merges multiple / into one.
  • Resolves and eliminates .. and . if any.
  • Appends a trailing / if one is not present, and there is no file extension.

It will respond with a permanent redirect if the path was cleaned.

use actix_web::{web, App, HttpResponse};

let app = App::new()
    .wrap(actix_clean_path::CleanPath)
    .route("/", web::get().to(|| HttpResponse::Ok()));

Dependencies

~26MB
~560K SLoC