title: Adding a header to a ResponseWriter
body: <p>I'm trying to contribute a fix for <a href="https://github.com/tonistiigi/dnsdock/issues/68" rel="nofollow noreferrer">this issue</a>, and tried something similar to <a href="https://stackoverflow.com/questions/12830095/setting-http-headers-in-golang/12830156#12830156">this</a>, but no matter what header I try to set, I don't see it in the http response I am trying to modify.</p>
  
  <p><a href="https://github.com/tonistiigi/dnsdock/blob/master/src/http.go#L43" rel="nofollow noreferrer">This</a> is the method I'm trying to change, and here is the line I tried to add : </p>
  
  <p><code>w.Header().Set("Content-Type", "application/json")</code>.</p>
  
  <p>The full method : </p>
  
  <pre><code>func (s *HTTPServer) getServices(w http.ResponseWriter, req *http.Request) {
      w.Header().Set("Content-Type", "application/json")
      if err := json.NewEncoder(w).Encode(s.list.GetAllServices()); err != nil {
          log.Println("Error encoding: ", err)
          http.Error(w, err.Error(), http.StatusInternalServerError)
      }
  }
  </code></pre>
  
  <p>I would expect the header to change, but it always is <code>text/plain; charset=utf-8</code></p>
  
  <p>Disclaimer: this is the first piece of code I wrote (or rather, copy/pasted/adapted) in Go.</p>