title: Can you return json in golang http.Error?
body: <p>Can you return json when <code>http.Error</code> is called?</p>
  
  <pre><code>        myObj := MyObj{
              MyVar: myVar}
  
          data, err := json.Marshal(myObj)
          if err != nil {
              http.Error(w, err.Error(), http.StatusInternalServerError)
              return 
          }
          w.Write(data)
          w.Header().Set("Content-Type", "application/json")
  
          http.Error(w, "some error happened", http.StatusInternalServerError)
  </code></pre>
  
  <p>I see that it returns <code>200</code> with no <code>json</code> but the json is embed in <code>text</code></p>