From f49b42f70f902d4da1e0fa4080e99164b331b716 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sun, 29 Apr 2018 16:35:04 -0700 Subject: Use vanilla HTTP handlers (refactoring) --- http/response/xml/xml.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 http/response/xml/xml.go (limited to 'http/response/xml/xml.go') diff --git a/http/response/xml/xml.go b/http/response/xml/xml.go new file mode 100644 index 00000000..9e37e875 --- /dev/null +++ b/http/response/xml/xml.go @@ -0,0 +1,23 @@ +// Copyright 2018 Frédéric Guillot. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package xml + +import ( + "fmt" + "net/http" +) + +// OK sends a XML document. +func OK(w http.ResponseWriter, data string) { + w.Header().Set("Content-Type", "text/xml") + w.Write([]byte(data)) +} + +// Attachment forces the download of a XML document. +func Attachment(w http.ResponseWriter, filename, data string) { + w.Header().Set("Content-Type", "text/xml") + w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filename)) + w.Write([]byte(data)) +} -- cgit v1.2.3