From a1dc5a6bd18b5dfbce2ff979b2d703f050c124da Mon Sep 17 00:00:00 2001 From: ami44 Date: Sat, 30 Dec 2017 16:24:50 +0100 Subject: [PATCH] update examples/tls/README --- examples/tls/Cargo.toml | 4 ++-- examples/tls/README.md | 15 +++++++++++++-- examples/tls/src/main.rs | 8 +++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/examples/tls/Cargo.toml b/examples/tls/Cargo.toml index fbb22fb77..eda5e5fc8 100644 --- a/examples/tls/Cargo.toml +++ b/examples/tls/Cargo.toml @@ -9,5 +9,5 @@ path = "src/main.rs" [dependencies] env_logger = "0.4" -actix = "^0.3.1" -actix-web = { git = "https://github.com/actix/actix-web.git", features=["alpn"] } +actix = { version = "^0.3.5" } +actix-web = { git = "https://github.com/actix/actix-web", features=["signal", "alpn"] } diff --git a/examples/tls/README.md b/examples/tls/README.md index bd1f2400d..1bc9ba3b7 100644 --- a/examples/tls/README.md +++ b/examples/tls/README.md @@ -1,5 +1,16 @@ # tls example -To start server use command: `cargo run` +## Usage -Test command: `curl -v https://127.0.0.1:8080/index.html --compress -k` +### server + +```bash +cd actix-web/examples/tls +cargo run (or ``cargo watch -x run``) +# Started http server: 127.0.0.1:8443 +``` + +### web client + +- curl: ``curl -v https://127.0.0.1:8443/index.html --compress -k`` +- browser: [https://127.0.0.1:8443/index.html](https://127.0.0.1:8080/index.html) diff --git a/examples/tls/src/main.rs b/examples/tls/src/main.rs index 8dce633e6..bf0c3eed0 100644 --- a/examples/tls/src/main.rs +++ b/examples/tls/src/main.rs @@ -7,6 +7,8 @@ use std::fs::File; use std::io::Read; use actix_web::*; +use actix::Arbiter; +use actix::actors::signal::{ProcessSignals, Subscribe}; /// somple handle fn index(req: HttpRequest) -> Result { @@ -29,7 +31,7 @@ fn main() { file.read_to_end(&mut pkcs12).unwrap(); let pkcs12 = Pkcs12::from_der(&pkcs12).unwrap().parse("12345").unwrap(); - HttpServer::new( + let addr = HttpServer::new( || Application::new() // enable logger .middleware(middleware::Logger::default()) @@ -45,6 +47,10 @@ fn main() { .bind("127.0.0.1:8443").unwrap() .start_ssl(&pkcs12).unwrap(); + // Subscribe to unix signals + let signals = Arbiter::system_registry().get::(); + signals.send(Subscribe(addr.subscriber())); + println!("Started http server: 127.0.0.1:8443"); let _ = sys.run(); }