title: Accessing the underlying socket of a net/http response
body: <p>I'm new to Go and evaluating it for a project.</p>
  
  <p>I'm trying to write a custom handler to serve files with <code>net/http</code>.
  I can't use the default <code>http.FileServer()</code> handler because I need to have access to the underlying socket (the internal <code>net.Conn</code>) so I can perform some informational platform specific "syscall" calls on it (mainly <code>TCP_INFO</code>).</p>
  
  <p>More precisly: I need to access the underlying socket of the <code>http.ResponseWriter</code> in the handler function:</p>
  
  <pre><code>func myHandler(w http.ResponseWriter, r *http.Request) {
  ...
  // I need the net.Conn of w
  ...
  }
  </code></pre>
  
  <p>used in</p>
  
  <pre><code>http.HandleFunc("/", myHandler)
  </code></pre>
  
  <p>Is there a way to this. I looked at how <code>websocket.Upgrade</code> does this but it uses <code>Hijack()</code> which is 'too much' because then I have to code 'speaking http' over the raw tcp socket I get. I just want a reference to the socket and not taking over completely.</p>