1
0
mirror of https://github.com/actix/actix-website synced 2025-06-27 07:29:02 +02:00

Update http2

This commit is contained in:
Yuki Okushi
2019-12-29 01:37:19 +09:00
parent e018ce4278
commit 9da187a36c
3 changed files with 10 additions and 9 deletions

View File

@ -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"] }

View File

@ -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>