1
0
mirror of https://github.com/actix/examples synced 2025-06-27 01:27:43 +02:00

Use captured args in format string (#558)

This commit is contained in:
Yuri Astrakhan
2022-06-07 22:53:38 -04:00
committed by GitHub
parent 912de4aa46
commit db5f00e771
37 changed files with 57 additions and 60 deletions

View File

@ -22,12 +22,12 @@ async fn favicon() -> Result<impl Responder> {
/// simple index handler
#[get("/welcome")]
async fn welcome(req: HttpRequest, session: Session) -> Result<HttpResponse> {
println!("{:?}", req);
println!("{req:?}");
// session
let mut counter = 1;
if let Some(count) = session.get::<i32>("counter")? {
println!("SESSION value: {}", count);
println!("SESSION value: {count}");
counter = count + 1;
}
@ -63,7 +63,7 @@ async fn response_body(path: web::Path<String>) -> HttpResponse {
/// handler with path parameters like `/user/{name}/`
async fn with_param(req: HttpRequest, path: web::Path<(String,)>) -> HttpResponse {
println!("{:?}", req);
println!("{req:?}");
HttpResponse::Ok()
.content_type(ContentType::plaintext())
@ -110,7 +110,7 @@ async fn main() -> io::Result<()> {
// redirect
.service(
web::resource("/").route(web::get().to(|req: HttpRequest| async move {
println!("{:?}", req);
println!("{req:?}");
HttpResponse::Found()
.insert_header((header::LOCATION, "static/welcome.html"))
.finish()