Crates.io | mco-http-rustls |
lib.rs | mco-http-rustls |
version | 0.1.5 |
source | src |
created_at | 2023-12-07 13:06:05.017604 |
updated_at | 2023-12-08 07:27:13.386069 |
description | Rustls+hyper integration for pure rust HTTPS |
homepage | https://github.com/ctz/hyper-rustls |
repository | https://github.com/ctz/hyper-rustls |
max_upload_size | |
id | 1060966 |
size | 14,033 |
mco-http support rustls
use example:
mco-http-rustls = "0.1"
#[deny(unused_variables)]
extern crate mco_http;
extern crate fast_log;
use std::fs::File;
use std::io::Read;
use fast_log::config::Config;
use mco_http::server::{Request, Response};
use mco_http_rustls::TlsServer;
fn main() {
let _ = fast_log::init(Config::new().console());
let mut f_cert = File::open("examples/rustls/cert.pem").unwrap();
let mut f_key = File::open("examples/rustls/key.rsa").unwrap();
let mut buf =vec![];
_ = f_cert.read_to_end(&mut buf);
let mut buf2 =vec![];
_ = f_key.read_to_end(&mut buf2);
let ssl = TlsServer::new(vec![buf],buf2);
let _listening = mco_http::Server::https("0.0.0.0:3000", ssl).unwrap()
.handle(|_req:Request,resp:Response|{
resp.send(b"Hello World!").unwrap();
});
println!("Listening on https://127.0.0.1:3000");
}