Skip to content

Commit 9da187a

Browse files
committed
Update http2
1 parent e018ce4 commit 9da187a

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

content/docs/http2.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ weight: 250
1313
> Currently, only `rust-openssl` has support.
1414
1515
`alpn` negotiation requires enabling the feature. When enabled, `HttpServer` provides the
16-
[bind_ssl][bindssl] method.
16+
[bind_openssl][bindopenssl] method.
1717

1818
```toml
1919
[dependencies]
20-
actix-web = { version = "{{< actix-version "actix-web" >}}", features = ["ssl"] }
20+
actix-web = { version = "{{< actix-version "actix-web" >}}", features = ["openssl"] }
2121
openssl = { version = "0.10", features = ["v110"] }
2222
```
2323
{{< include-example example="http2" file="main.rs" section="main" >}}
@@ -30,6 +30,6 @@ connection and tls connection. [rfc section 3.4][rfcsection34].
3030
3131
[rfcsection32]: https://http2.github.io/http2-spec/#rfc.section.3.2
3232
[rfcsection34]: https://http2.github.io/http2-spec/#rfc.section.3.4
33-
[bindssl]: https://docs.rs/actix-web/1.0.2/actix_web/struct.HttpServer.html#method.bind_ssl
33+
[bindopenssl]: https://docs.rs/actix-web/2/actix_web/struct.HttpServer.html#method.bind_openssl
3434
[tlsalpn]: https://tools.ietf.org/html/rfc7301
3535
[examples]: https://github.com/actix/examples/tree/master/tls

examples/http2/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ version = "1.0.0"
44
edition = "2018"
55

66
[dependencies]
7-
actix-web = { version = "1.0", features = ["ssl"] }
7+
actix-web = { version = "2.0", features = ["openssl"] }
8+
actix-rt = "1.0"
89
openssl = { version = "0.10", features = ["v110"] }

examples/http2/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
use actix_web::{web, App, HttpRequest, HttpServer, Responder};
33
use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
44

5-
fn index(_req: HttpRequest) -> impl Responder {
5+
async fn index(_req: HttpRequest) -> impl Responder {
66
"Hello."
77
}
88

9-
fn main() {
9+
#[actix_rt::main]
10+
async fn main() -> std::io::Result<()> {
1011
// load ssl keys
1112
// to create a self-signed temporary cert for testing:
1213
// `openssl req -x509 -newkey rsa:4096 -nodes -keyout key.pem -out cert.pem -days 365 -subj '/CN=localhost'`
@@ -17,9 +18,8 @@ fn main() {
1718
builder.set_certificate_chain_file("cert.pem").unwrap();
1819

1920
HttpServer::new(|| App::new().route("/", web::get().to(index)))
20-
.bind_ssl("127.0.0.1:8088", builder)
21-
.unwrap()
21+
.bind_openssl("127.0.0.1:8088", builder)?
2222
.run()
23-
.unwrap();
23+
.await
2424
}
2525
// </main>

0 commit comments

Comments
 (0)