1
0
mirror of https://github.com/actix/examples synced 2025-06-26 17:17:42 +02:00

standardize examples

This commit is contained in:
Rob Ede
2023-03-14 03:11:49 +00:00
parent ca6eaee52e
commit 6424e4e023
30 changed files with 169 additions and 395 deletions

View File

@ -1,9 +1,10 @@
[package]
name = "openssl-example"
name = "tls-openssl"
version = "1.0.0"
edition = "2021"
[dependencies]
actix-web = { workspace = true, features = ["openssl"] }
env_logger.workspace = true
log.workspace = true
openssl = "0.10"

View File

@ -13,10 +13,7 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Error> {
#[actix_web::main]
async fn main() -> io::Result<()> {
std::env::set_var("RUST_LOG", "actix_web=debug");
env_logger::init();
println!("Started http server: https://127.0.0.1:8443");
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
// load TLS keys
let mut builder = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap();
@ -25,6 +22,8 @@ async fn main() -> io::Result<()> {
.unwrap();
builder.set_certificate_chain_file("cert.pem").unwrap();
log::info!("starting HTTPS server at http://localhost:8443");
HttpServer::new(|| {
App::new()
// enable logger