2019-06-12 18:14:10 -04:00
|
|
|
// <request-routing>
|
2023-01-09 04:52:42 -05:00
|
|
|
use actix_web::{get, web, App, HttpServer, Responder};
|
2019-06-12 18:14:10 -04:00
|
|
|
|
2022-07-16 11:59:20 +02:00
|
|
|
#[get("/")]
|
2023-01-09 04:52:42 -05:00
|
|
|
async fn index() -> impl Responder {
|
|
|
|
"Hello, World!"
|
2019-06-12 18:14:10 -04:00
|
|
|
}
|
|
|
|
|
2023-01-09 04:52:42 -05:00
|
|
|
#[get("/{name}")]
|
|
|
|
async fn hello(name: web::Path<String>) -> impl Responder {
|
|
|
|
format!("Hello {}!", &name)
|
2019-06-12 18:14:10 -04:00
|
|
|
}
|
|
|
|
|
2020-09-12 16:21:54 +01:00
|
|
|
#[actix_web::main]
|
2019-12-29 02:09:52 +09:00
|
|
|
async fn main() -> std::io::Result<()> {
|
2023-01-09 04:52:42 -05:00
|
|
|
HttpServer::new(|| App::new().service(index).service(hello))
|
|
|
|
.bind(("127.0.0.1", 8080))?
|
|
|
|
.run()
|
|
|
|
.await
|
2019-06-12 18:14:10 -04:00
|
|
|
}
|
|
|
|
// </request-routing>
|