chore: reorg

This commit is contained in:
2020-10-17 11:47:07 +08:00
parent 9d4d830115
commit a034988643
56 changed files with 13431 additions and 0 deletions

1347
__web/rweb/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

11
__web/rweb/Cargo.toml Normal file
View File

@@ -0,0 +1,11 @@
[package]
name = "rweb"
version = "0.1.0"
authors = ["Hatter Jiang <jht5945@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tokio = "0.2"
rweb = "0.4.0"

32
__web/rweb/src/main.rs Normal file
View File

@@ -0,0 +1,32 @@
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;
}