xml.go 877 B

123456789101112131415161718192021222324252627
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package xml // import "miniflux.app/v2/internal/http/response/xml"
  4. import (
  5. "net/http"
  6. "miniflux.app/v2/internal/http/response"
  7. )
  8. // OK writes a standard XML response with a status 200 OK.
  9. func OK[T []byte | string](w http.ResponseWriter, r *http.Request, body T) {
  10. builder := response.New(w, r)
  11. builder.WithHeader("Content-Type", "text/xml; charset=utf-8")
  12. builder.WithBody(body)
  13. builder.Write()
  14. }
  15. // Attachment forces the XML document to be downloaded by the web browser.
  16. func Attachment[T []byte | string](w http.ResponseWriter, r *http.Request, filename string, body T) {
  17. builder := response.New(w, r)
  18. builder.WithHeader("Content-Type", "text/xml; charset=utf-8")
  19. builder.WithAttachment(filename)
  20. builder.WithBody(body)
  21. builder.Write()
  22. }