xml.go 461 B

123456789101112131415161718192021
  1. // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
  2. // Use of this source code is governed by a MIT style
  3. // license that can be found in the LICENSE file.
  4. package render
  5. import (
  6. "encoding/xml"
  7. "net/http"
  8. )
  9. type XML struct {
  10. Data interface{}
  11. }
  12. const xmlContentType = "application/xml; charset=utf-8"
  13. func (r XML) Write(w http.ResponseWriter) error {
  14. w.Header().Set("Content-Type", xmlContentType)
  15. return xml.NewEncoder(w).Encode(r.Data)
  16. }