use rweb::*;

#[get("/name")]
fn name() -> String {
   "Tom\n".into()
}

#[get("/name/{n}")]
fn name_n(n: String) -> String {
    format!("Hello: {}\n", n)
}

#[get("/json_list")]
fn get_json_list() -> Json<Vec<String>> {
    vec![ "1".into(), "2".into(), "3".into() ].into()
}

#[get("/")]
fn root() -> String {
   "Root\n".into()
}

#[tokio::main]
async fn main() {
    println!("Start listen on: 127.0.0.1:8080 ...");
    serve(
        root()
        .or(name())
        .or(name_n())
        .or(get_json_list())
    ).run(([127, 0, 0, 1], 8080)).await;
}
