1
0
mirror of https://github.com/actix/actix-website synced 2025-02-08 22:36:07 +01:00
2020-09-12 16:21:54 +01:00

28 lines
640 B
Rust

use actix_web::{get, web, App, HttpResponse, HttpServer};
// <scope>
#[get("/show")]
async fn show_users() -> HttpResponse {
HttpResponse::Ok().body("Show users")
}
#[get("/show/{id}")]
async fn user_detail(path: web::Path<(u32,)>) -> HttpResponse {
HttpResponse::Ok().body(format!("User detail: {}", path.into_inner().0))
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new().service(
web::scope("/users")
.service(show_users)
.service(user_detail),
)
})
.bind("127.0.0.1:8080")?
.run()
.await
}
// </scope>