xml.go 293 B

1234567891011121314151617
  1. package render
  2. import (
  3. "encoding/xml"
  4. "net/http"
  5. )
  6. type XML struct {
  7. Data interface{}
  8. }
  9. const xmlContentType = "application/xml; charset=utf-8"
  10. func (r XML) Write(w http.ResponseWriter) error {
  11. w.Header().Set("Content-Type", xmlContentType)
  12. return xml.NewEncoder(w).Encode(r.Data)
  13. }