title: How to use routes attributes macros for multiple methods in Actix-Web
body: <p>In the <a href="https://github.com/actix/actix-web" rel="noreferrer">Actix Web Framework</a>, how does one use the route attributes macros (<code>#[http_method("route")]</code>) to bind multiple http methods to one function?</p>
  
  <p>For example, I have this trivial endpoint:</p>
  
  <pre class="lang-rust prettyprint-override"><code>/// Returns a UUID4.
  #[get("/uuid")]
  async fn uuid_v4() -&gt; impl Responder {
      HttpResponse::Ok().json(Uuid {
          uuid: uuid::Uuid::new_v4(),
      })
  }
  </code></pre>
  
  <p>I would like to have the same endpoint handle <code>HEAD</code> requests, <strong>how do I do this?</strong>
  My initial approach was to just stack up the macros:</p>
  
  <pre class="lang-rust prettyprint-override"><code>/// Returns a UUID4.
  #[get("/uuid")]
  #[head("/uuid")]
  async fn uuid_v4() -&gt; impl Responder {
      HttpResponse::Ok().json(Uuid {
          uuid: uuid::Uuid::new_v4(),
      })
  }
  </code></pre>
  
  <p>But I do get a compilation error:</p>
  
  <pre><code>    |
  249 | async fn uuid_v4() -&gt; impl Responder {
      |          ^^^^^^^ the trait `actix_web::handler::Factory&lt;_, _, _&gt;` is not implemented for `&lt;uuid_v4 as actix_web::service::HttpServiceFactory&gt;::register::uuid_v4`
  </code></pre>
  
  <p><em>I have gone through the <code>actix-web</code> and <code>actix-web-codegen docs</code> and didn't find anything addressing this</em></p>