2023-12-12 15:48:28 +08:00
|
|
|
use actix_web::{get, web, App, HttpServer, Responder};
|
|
|
|
|
|
|
|
|
|
#[get("/")]
|
|
|
|
|
async fn index() -> impl Responder {
|
|
|
|
|
"Hello, World!"
|
2023-12-12 15:43:12 +08:00
|
|
|
}
|
2023-12-12 15:48:28 +08:00
|
|
|
|
|
|
|
|
#[get("/{name}")]
|
|
|
|
|
async fn hello(name: web::Path<String>) -> impl Responder {
|
|
|
|
|
format!("Hello {}!", &name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[actix_web::main]
|
|
|
|
|
async fn main() -> std::io::Result<()> {
|
|
|
|
|
HttpServer::new(|| App::new().service(index).service(hello))
|
|
|
|
|
.bind(("127.0.0.1", 9090))?
|
|
|
|
|
.run()
|
|
|
|
|
.await
|
|
|
|
|
}
|