mirror of
https://github.com/actix/actix-website
synced 2025-06-27 15:39:02 +02:00
Update main-example
This commit is contained in:
@ -1,20 +1,20 @@
|
||||
// <main-example>
|
||||
use actix_web::{web, App, HttpRequest, HttpServer, Responder};
|
||||
|
||||
fn greet(req: HttpRequest) -> impl Responder {
|
||||
async fn greet(req: HttpRequest) -> impl Responder {
|
||||
let name = req.match_info().get("name").unwrap_or("World");
|
||||
format!("Hello {}!", &name)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
#[actix_rt::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
HttpServer::new(|| {
|
||||
App::new()
|
||||
.route("/", web::get().to(greet))
|
||||
.route("/{name}", web::get().to(greet))
|
||||
})
|
||||
.bind("127.0.0.1:8088")
|
||||
.unwrap()
|
||||
.bind("127.0.0.1:8088")?
|
||||
.run()
|
||||
.unwrap();
|
||||
.await
|
||||
}
|
||||
// </main-example>
|
||||
|
Reference in New Issue
Block a user