]> piware.de Git - learn-rust.git/commitdiff
actix-server: Make hello route work with HEAD
authorMartin Pitt <martin@piware.de>
Sat, 10 Dec 2022 11:34:07 +0000 (12:34 +0100)
committerMartin Pitt <martin@piware.de>
Sat, 10 Dec 2022 11:34:07 +0000 (12:34 +0100)
This is a little bit tricky:
https://github.com/actix/actix-web/issues/2702

actix-server/src/main.rs

index c73e7add5ee333cfecb7b72a2ac64e8595940b65..4a43ef55b36d8b1f2ccf31f84d11979a1efd35fd 100644 (file)
@@ -1,11 +1,11 @@
 use std::path::Path;
 
-use actix_web::{get, web, App, HttpRequest, HttpServer, Responder, Result};
+use actix_web::{get, route, web, App, HttpRequest, HttpServer, Responder, Result};
 use actix_web::http::header;
 use actix_web::middleware::Logger;
 use actix_files::{Files, NamedFile};
 
-#[get("/hello/{name}")]
+#[route("/hello/{name}", method="GET", method="HEAD")]
 async fn hello(params: web::Path<String>, req: HttpRequest) -> Result<String> {
     let name = params.into_inner();