use log::info; use thruster::ssl_server::SSLServer; use thruster::ThrusterServer; use thruster::{m, middleware_fn}; use thruster::{App, BasicContext as Ctx, Request}; use thruster::{MiddlewareNext, MiddlewareResult}; #[middleware_fn] async fn plaintext(mut context: Ctx, _next: MiddlewareNext) -> MiddlewareResult { let val = "Hello, World!"; context.body(val); Ok(context) } #[middleware_fn] async fn test_fn_404(mut context: Ctx, _next: MiddlewareNext) -> MiddlewareResult { context.body("404"); Ok(context) } fn main() { env_logger::init(); info!("Starting server..."); let app = App::::new_basic() .get("/plaintext", m![plaintext]) .set404(m![test_fn_404]); let mut server = SSLServer::new(app); server.cert(include_bytes!("identity.p12").to_vec()); server.cert_pass("asdfasdfasdf"); server.start("0.0.0.0", 4321); }