gin/render/xml.go

18 lines
377 B
Go
Raw Normal View History

package render
import (
"encoding/xml"
"net/http"
)
type xmlRender struct{}
func (_ xmlRender) Render(w http.ResponseWriter, code int, data ...interface{}) error {
return WriteXML(w, code, data[0])
}
func WriteXML(w http.ResponseWriter, code int, data interface{}) error {
2015-05-10 23:02:17 +00:00
writeHeader(w, code, "application/xml; charset=utf-8")
return xml.NewEncoder(w).Encode(data)
}