fix: write xml header

This commit is contained in:
Michael Kriese 2024-01-24 00:12:36 +01:00
parent 5f837efc15
commit a715984a42
No known key found for this signature in database
GPG key ID: B83F553A0724D44E

View file

@ -141,6 +141,7 @@ func (b *Base) JSON(status int, content any) {
func (b *Base) XML(status int, content any) {
b.Resp.Header().Set("Content-Type", "application/xml;charset=utf-8")
b.Resp.WriteHeader(status)
b.Resp.Write([]byte(xml.Header))
if err := xml.NewEncoder(b.Resp).Encode(content); err != nil {
log.Error("Render XML failed: %v", err)
}