diff --git a/examples/tls/Cargo.toml b/examples/tls/Cargo.toml index fbb22fb7..eda5e5fc 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 bd1f2400..1bc9ba3b 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 8dce633e..bf0c3eed 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(); }