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

1475
__web/actix-web/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
[package]
name = "actix-web"
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]
actix-web = "2"
actix-rt = "1"

View File

@@ -0,0 +1,34 @@
use actix_web::{
get, web, App, HttpServer, Responder, HttpRequest, HttpResponse,
};
#[get("/{id}/{name}/index.html")]
async fn index(info: web::Path<(u32, String)>) -> impl Responder {
format!("Hello {}! id:{}", info.1, info.0)
}
#[get("/name")]
async fn index_name() -> impl Responder {
format!("Hello name!\n")
}
async fn index2(req: HttpRequest) -> HttpResponse {
println!("{:?}", req);
HttpResponse::Ok()
.content_type("text/plain")
.body("Welcome!\n")
}
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
println!("Listen at: http://127.0.0.1:8080/");
HttpServer::new(|| App::new()
.service(index)
.service(index_name)
.service(web::resource("/").to(index2))
)
.bind("127.0.0.1:8080")?
.run()
.await
}