xml.go 630 B

1234567891011121314151617181920212223
  1. // Copyright 2018 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 xml
  5. import (
  6. "fmt"
  7. "net/http"
  8. )
  9. // OK sends a XML document.
  10. func OK(w http.ResponseWriter, data string) {
  11. w.Header().Set("Content-Type", "text/xml")
  12. w.Write([]byte(data))
  13. }
  14. // Attachment forces the download of a XML document.
  15. func Attachment(w http.ResponseWriter, filename, data string) {
  16. w.Header().Set("Content-Type", "text/xml")
  17. w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filename))
  18. w.Write([]byte(data))
  19. }