use hypers::prelude::*; use hypers_middleware::Cors; #[get("return_str")] async fn return_str() -> &'static str { "return_str" } fn main() -> Result<()> { let mut root = Router::new("/"); let cors = Cors::new() .allow_origin("*") .allow_methods(vec!["GET", "POST"]) .allow_headers(vec![ "CONTENT-TYPE", "Access-Control-Request-Method", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Access-Control-Max-Age", ]); root.hook(cors, vec!["/"], None); root.handler(return_str); println!("root = {:#?}",root); hypers::run(root, "127.0.0.1:7878") }