mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
update examples/tls/README
This commit is contained in:
parent
8e580ef7b9
commit
a1dc5a6bd1
@ -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"] }
|
||||
|
@ -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)
|
||||
|
@ -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<HttpResponse> {
|
||||
@ -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::<ProcessSignals>();
|
||||
signals.send(Subscribe(addr.subscriber()));
|
||||
|
||||
println!("Started http server: 127.0.0.1:8443");
|
||||
let _ = sys.run();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user