Using keyed initialization to fix app-engine integration

This commit is contained in:
Manu Mtz-Almeida 2014-07-13 16:53:46 +02:00
parent f63a354b40
commit 94bc35bb2d
1 changed files with 7 additions and 4 deletions

11
gin.go
View File

@ -80,20 +80,23 @@ type (
// Allows type H to be used with xml.Marshal // Allows type H to be used with xml.Marshal
func (h H) MarshalXML(e *xml.Encoder, start xml.StartElement) error { func (h H) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
start.Name = xml.Name{"", "map"} start.Name = xml.Name{
Space: "",
Local: "map",
}
if err := e.EncodeToken(start); err != nil { if err := e.EncodeToken(start); err != nil {
return err return err
} }
for key, value := range h { for key, value := range h {
elem := xml.StartElement{ elem := xml.StartElement{
xml.Name{"", key}, Name: xml.Name{Space: "", Local: key},
[]xml.Attr{}, Attr: []xml.Attr{},
} }
if err := e.EncodeElement(value, elem); err != nil { if err := e.EncodeElement(value, elem); err != nil {
return err return err
} }
} }
if err := e.EncodeToken(xml.EndElement{start.Name}); err != nil { if err := e.EncodeToken(xml.EndElement{Name: start.Name}); err != nil {
return err return err
} }
return nil return nil