mirror of
https://github.com/actix/actix-website
synced 2025-06-27 15:39:02 +02:00
First pass at Http2 section.
This commit is contained in:
@ -24,4 +24,5 @@ exclude = [
|
||||
"middleware",
|
||||
"static-files",
|
||||
"websockets",
|
||||
"http20",
|
||||
]
|
||||
|
9
examples/http20/Cargo.toml
Normal file
9
examples/http20/Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "http20"
|
||||
version = "0.1.0"
|
||||
authors = ["Cameron Dershem <cameron@pinkhatbeard.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-web = { version = "1.0", features = ["ssl"] }
|
||||
openssl = { version = "0.10", features = ["v110"] }
|
21
examples/http20/src/main.rs
Normal file
21
examples/http20/src/main.rs
Normal file
@ -0,0 +1,21 @@
|
||||
// <main>
|
||||
use actix_web::{web, App, HttpRequest, HttpServer, Responder};
|
||||
use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
|
||||
|
||||
fn index(_req: HttpRequest) -> impl Responder {
|
||||
"Hello."
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// load ssl keys
|
||||
let mut builder = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap();
|
||||
builder
|
||||
.set_private_key_file("key.pem", SslFiletype::PEM)
|
||||
.unwrap();
|
||||
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();
|
||||
}
|
||||
// </main>
|
Reference in New Issue
Block a user