Skip to content

Commit

Permalink
make TrailingSlash enum accessible (actix#1673)
Browse files Browse the repository at this point in the history
Co-authored-by: Damian Lesiuk <[email protected]>
  • Loading branch information
Lesiuk and Damian Lesiuk authored Sep 12, 2020
1 parent 64a2c13 commit a4546f0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ guide/build/

# These are backup files generated by rustfmt
**/*.rs.bk

# Configuration directory generated by CLion
.idea
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changes

## Unreleased - 2020-xx-xx

### Changed
* `middleware::normalize::TrailingSlash` enum is now accessible. [#1673]

## 3.0.0 - 2020-09-11
* No significant changes from `3.0.0-beta.4`.
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod condition;
mod defaultheaders;
pub mod errhandlers;
mod logger;
mod normalize;
pub mod normalize;

pub use self::condition::Condition;
pub use self::defaultheaders::DefaultHeaders;
Expand Down
17 changes: 16 additions & 1 deletion tests/test_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use futures_util::ready;
use rand::{distributions::Alphanumeric, Rng};

use actix_web::dev::BodyEncoding;
use actix_web::middleware::Compress;
use actix_web::middleware::normalize::TrailingSlash;
use actix_web::middleware::{Compress, NormalizePath};
use actix_web::{dev, test, web, App, Error, HttpResponse};

const STR: &str = "Hello World Hello World Hello World Hello World Hello World \
Expand Down Expand Up @@ -866,6 +867,20 @@ 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() {
Expand Down

0 comments on commit a4546f0

Please sign in to comment.