Skip to content
Myr

xml.go

This file

Path

render/xml.go

28 lines · 730 bytes · Go

Last changed by

Not known.

History of this file

Take it

1// Copyright 2014 Manu Martinez-Almeida. All rights reserved.2// Use of this source code is governed by a MIT style3// license that can be found in the LICENSE file.45package render67import (8	"encoding/xml"9	"net/http"10)1112// XML contains the given interface object.13type XML struct {14	Data any15}1617var xmlContentType = []string{"application/xml; charset=utf-8"}1819// Render (XML) encodes the given interface object and writes data with custom ContentType.20func (r XML) Render(w http.ResponseWriter) error {21	r.WriteContentType(w)22	return xml.NewEncoder(w).Encode(r.Data)23}2425// WriteContentType (XML) writes XML ContentType for response.26func (r XML) WriteContentType(w http.ResponseWriter) {27	writeContentType(w, xmlContentType)28}