xml_response.go 528 B

123456789101112131415161718192021
  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. type XmlResponse struct {
  10. writer http.ResponseWriter
  11. request *http.Request
  12. }
  13. func (x *XmlResponse) Download(filename, data string) {
  14. x.writer.Header().Set("Content-Type", "text/xml")
  15. x.writer.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filename))
  16. x.writer.Write([]byte(data))
  17. }