Created
June 13, 2021 17:27
-
-
Save oscartbeaumont/471772733c83efab04238a4b189be751 to your computer and use it in GitHub Desktop.
Rust Actix Scope Middleware
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "rust-actix-scope-middleware-bug" | |
version = "0.1.0" | |
authors = ["Oscar Beaumont <[email protected]>"] | |
edition = "2018" | |
[dependencies] | |
actix-web = "3.3.2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use actix_web::{middleware, web, App, HttpServer, Responder}; | |
async fn index() -> impl Responder { | |
"Hello World" | |
} | |
async fn index_compressed() -> impl Responder { | |
"Hello World Compressed!" | |
} | |
#[actix_web::main] | |
async fn main() -> std::io::Result<()> { | |
HttpServer::new(|| { | |
App::new().route("/", web::get().to(index)).service( | |
web::scope("") | |
.wrap(middleware::Compress::default()) | |
.route("/compressed", web::get().to(index_compressed)), | |
) | |
}) | |
.bind(("0.0.0.0", 9000))? | |
.run() | |
.await | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment