diff --git a/.gitignore b/.gitignore index 885694946..638a4397a 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,4 @@ guide/build/ **/*.rs.bk # Configuration directory generated by CLion -.idea \ No newline at end of file +.idea diff --git a/src/middleware/mod.rs b/src/middleware/mod.rs index 3a9b39542..12c12a98c 100644 --- a/src/middleware/mod.rs +++ b/src/middleware/mod.rs @@ -14,4 +14,4 @@ pub mod normalize; pub use self::condition::Condition; pub use self::defaultheaders::DefaultHeaders; pub use self::logger::Logger; -pub use self::normalize::NormalizePath; \ No newline at end of file +pub use self::normalize::NormalizePath; diff --git a/tests/test_server.rs b/tests/test_server.rs index fa8a93f06..8d143b963 100644 --- a/tests/test_server.rs +++ b/tests/test_server.rs @@ -16,8 +16,9 @@ use futures_util::ready; use rand::{distributions::Alphanumeric, Rng}; use actix_web::dev::BodyEncoding; -use actix_web::middleware::Compress; +use actix_web::middleware::{Compress, NormalizePath}; use actix_web::{dev, test, web, App, Error, HttpResponse}; +use actix_web::middleware::normalize::TrailingSlash; const STR: &str = "Hello World Hello World Hello World Hello World Hello World \ Hello World Hello World Hello World Hello World Hello World \ @@ -866,6 +867,22 @@ async fn test_slow_request() { assert!(data.starts_with("HTTP/1.1 408 Request Timeout")); } +#[actix_rt::test] +async fn test_normalize() { + let srv = test::start_with(test::config().h1(), || { + App::new() + .wrap(NormalizePath::new(TrailingSlash::Trim)) + .service(web::resource("/one").route(web::to(|| HttpResponse::Ok().finish()))) + }); + + let response = srv + .get("/one/") + .send() + .await + .unwrap(); + assert!(response.status().is_success()); +} + // #[cfg(feature = "openssl")] // #[actix_rt::test] // async fn test_ssl_handshake_timeout() {