Fast path for setting headers.

- No heap allocation
- No indirection
- CanonicalMIMEHeaderKey() is not called
This commit is contained in:
Manu Mtz-Almeida
2015-05-23 16:39:25 +02:00
parent 35fd7fb480
commit a2105ce34c
4 changed files with 9 additions and 9 deletions
+2 -2
View File
@@ -13,9 +13,9 @@ type XML struct {
Data interface{}
}
const xmlContentType = "application/xml; charset=utf-8"
var xmlContentType = []string{"application/xml; charset=utf-8"}
func (r XML) Write(w http.ResponseWriter) error {
w.Header().Set("Content-Type", xmlContentType)
w.Header()["Content-Type"] = xmlContentType
return xml.NewEncoder(w).Encode(r.Data)
}