diff --git a/content/docs/http2.md b/content/docs/http2.md index d64e395..c93c1e1 100644 --- a/content/docs/http2.md +++ b/content/docs/http2.md @@ -13,11 +13,11 @@ weight: 250 > Currently, only `rust-openssl` has support. `alpn` negotiation requires enabling the feature. When enabled, `HttpServer` provides the -[bind_ssl][bindssl] method. +[bind_openssl][bindopenssl] method. ```toml [dependencies] -actix-web = { version = "{{< actix-version "actix-web" >}}", features = ["ssl"] } +actix-web = { version = "{{< actix-version "actix-web" >}}", features = ["openssl"] } openssl = { version = "0.10", features = ["v110"] } ``` {{< include-example example="http2" file="main.rs" section="main" >}} @@ -30,6 +30,6 @@ connection and tls connection. [rfc section 3.4][rfcsection34]. [rfcsection32]: https://http2.github.io/http2-spec/#rfc.section.3.2 [rfcsection34]: https://http2.github.io/http2-spec/#rfc.section.3.4 -[bindssl]: https://docs.rs/actix-web/1.0.2/actix_web/struct.HttpServer.html#method.bind_ssl +[bindopenssl]: https://docs.rs/actix-web/2/actix_web/struct.HttpServer.html#method.bind_openssl [tlsalpn]: https://tools.ietf.org/html/rfc7301 [examples]: https://github.com/actix/examples/tree/master/tls diff --git a/examples/http2/Cargo.toml b/examples/http2/Cargo.toml index 5749e20..c9a0d58 100644 --- a/examples/http2/Cargo.toml +++ b/examples/http2/Cargo.toml @@ -4,5 +4,6 @@ version = "1.0.0" edition = "2018" [dependencies] -actix-web = { version = "1.0", features = ["ssl"] } +actix-web = { version = "2.0", features = ["openssl"] } +actix-rt = "1.0" openssl = { version = "0.10", features = ["v110"] } diff --git a/examples/http2/src/main.rs b/examples/http2/src/main.rs index a985211..3dc8599 100644 --- a/examples/http2/src/main.rs +++ b/examples/http2/src/main.rs @@ -2,11 +2,12 @@ use actix_web::{web, App, HttpRequest, HttpServer, Responder}; use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod}; -fn index(_req: HttpRequest) -> impl Responder { +async fn index(_req: HttpRequest) -> impl Responder { "Hello." } -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { // load ssl keys // to create a self-signed temporary cert for testing: // `openssl req -x509 -newkey rsa:4096 -nodes -keyout key.pem -out cert.pem -days 365 -subj '/CN=localhost'` @@ -17,9 +18,8 @@ fn main() { builder.set_certificate_chain_file("cert.pem").unwrap(); HttpServer::new(|| App::new().route("/", web::get().to(index))) - .bind_ssl("127.0.0.1:8088", builder) - .unwrap() + .bind_openssl("127.0.0.1:8088", builder)? .run() - .unwrap(); + .await } //