Exploring async and await with web programming
Knowing what we know about async programming, we can now see the main function in our web application in a different light, as follows:
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new( || {
App::new()
.route("/", web::get().to(greet))
.route("/{name}", web::get().to(greet))
.route("/say/hello", web::get().to(||
async { "Hello Again!" }))
})
.bind("127.0.0.1:8080")?
.workers(3)
.run()
.await
}
We know that our greet function is...