Skip to content
Myr

xml.go

This file

Path

render/xml.go

28 lines · 730 bytes · Go

Last changed by

chore: update go.mod and remove space from copyright (#3158)thinkeroubefore adoption4b68a5f

History of this file

Take it

The walk stopped after 200 commits: lines older than a550c56 point at it.

chore: update go.mod and remove space from copyright (#3158)thinkeroubefore adoption4b68a5f

line 1why, one step back
1// Copyright 2014 Manu Martinez-Almeida. All rights reserved.

chore: Add go1.17 for testing (#2828)Bo-Yi Wubefore adoptiona550c56

lines 2–13why, one step back
2// Use of this source code is governed by a MIT style
3// 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 {

test support go1.18 (#2990)thinkeroubefore adoption2bde107

line 14why, one step back
14 Data any

chore: Add go1.17 for testing (#2828)Bo-Yi Wubefore adoptiona550c56

lines 15–28why, one step back
15}
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}