xml_response.go 616 B

1234567891011121314151617181920212223
  1. // Copyright 2017 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package core
  5. import (
  6. "fmt"
  7. "net/http"
  8. )
  9. // XMLResponse handles XML responses.
  10. type XMLResponse struct {
  11. writer http.ResponseWriter
  12. request *http.Request
  13. }
  14. // Download force the download of a XML document.
  15. func (x *XMLResponse) Download(filename, data string) {
  16. x.writer.Header().Set("Content-Type", "text/xml")
  17. x.writer.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filename))
  18. x.writer.Write([]byte(data))
  19. }