gin/render/xml.go
2015-05-11 01:02:17 +02:00

18 lines
377 B
Go

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 {
writeHeader(w, code, "application/xml; charset=utf-8")
return xml.NewEncoder(w).Encode(data)
}