xml.go 882 B

12345678910111213141516171819202122232425262728
  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 // import "miniflux.app/http/response/xml"
  5. import (
  6. "net/http"
  7. "miniflux.app/http/response"
  8. )
  9. // OK writes a standard XML response with a status 200 OK.
  10. func OK(w http.ResponseWriter, r *http.Request, body interface{}) {
  11. builder := response.New(w, r)
  12. builder.WithHeader("Content-Type", "text/xml; charset=utf-8")
  13. builder.WithBody(body)
  14. builder.Write()
  15. }
  16. // Attachment forces the XML document to be downloaded by the web browser.
  17. func Attachment(w http.ResponseWriter, r *http.Request, filename string, body interface{}) {
  18. builder := response.New(w, r)
  19. builder.WithHeader("Content-Type", "text/xml; charset=utf-8")
  20. builder.WithAttachment(filename)
  21. builder.WithBody(body)
  22. builder.Write()
  23. }