fix: write xml header
This commit is contained in:
parent
5f837efc15
commit
a715984a42
|
@ -141,6 +141,7 @@ func (b *Base) JSON(status int, content any) {
|
||||||
func (b *Base) XML(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.Header().Set("Content-Type", "application/xml;charset=utf-8")
|
||||||
b.Resp.WriteHeader(status)
|
b.Resp.WriteHeader(status)
|
||||||
|
b.Resp.Write([]byte(xml.Header))
|
||||||
if err := xml.NewEncoder(b.Resp).Encode(content); err != nil {
|
if err := xml.NewEncoder(b.Resp).Encode(content); err != nil {
|
||||||
log.Error("Render XML failed: %v", err)
|
log.Error("Render XML failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue