mirror of
https://github.com/actix/actix-website
synced 2024-11-27 18:12:57 +01:00
Update http2
This commit is contained in:
parent
e018ce4278
commit
9da187a36c
@ -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
|
||||
|
@ -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"] }
|
||||
|
@ -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
|
||||
}
|
||||
// </main>
|
||||
|
Loading…
Reference in New Issue
Block a user