use log::info; use thruster::context::basic_hyper_context::{ generate_context, BasicHyperContext as Ctx, HyperRequest, }; use thruster::ssl_hyper_server::SSLHyperServer; use thruster::App; use thruster::ThrusterServer; use thruster::{m, middleware_fn}; 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::::create(generate_context, ()) .get("/plaintext", m![plaintext]) .set404(m![test_fn_404]); let mut server = SSLHyperServer::new(app); server.cert(include_bytes!("./cert.pem").to_vec()); server.key(include_bytes!("./key.pem").to_vec()); server.start("0.0.0.0", 4321); }