title: Go http, send incoming http.request to an other server using client.Do
body: <p>Here my use case</p>
  
  <p>We have one services "foobar"  which has two version <code>legacy</code>  and <code>version_2_of_doom</code>   (both in go)</p>
  
  <p>In order to make the transition from <code>legacy</code> to <code>version_2_of_doom</code> , we would like in a first time, to have the  two version alongside, and have the POST request (as there's only one  POST api call in this ) received on both.</p>
  
  <p>The way I see how to do it. Would be</p>
  
  <ol>
  <li><p>modifying the code of <code>legacy</code>  at the beginning of the handler, in order to duplicate the request to <code>version_2_of_doom</code></p>
  
  <pre><code> func(w http.ResponseWriter, req *http.Request) {
       req.URL.Host = "v2ofdoom.local:8081"
       req.Host = "v2ofdoom.local:8081"
       client := &amp;http.Client{}
       client.Do(req)
       // legacy code 
  </code></pre></li>
  </ol>
  
  <p>but it seems to not be as straightforward as this </p>
  
  <p>it fails with  <code>http: Request.RequestURI can't be set in client requests.</code> </p>
  
  <p>Is there a well-known method to do this kind of action (i.e transfering without touching) a <code>http.Request</code> to an other server ?</p>