MCPcopy Create free account
hub / github.com/kataras/iris / MarshalXML

Method MarshalXML

context/problem.go:224–246  ·  view source on GitHub ↗

MarshalXML makes this Problem XML-compatible content to render.

(e *xml.Encoder, start xml.StartElement)

Source from the content-addressed store, hash-verified

222
223// MarshalXML makes this Problem XML-compatible content to render.
224func (p Problem) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
225 if len(p) == 0 {
226 return nil
227 }
228
229 err := e.EncodeToken(start)
230 if err != nil {
231 return err
232 }
233
234 // toTitle := cases.Title(language.English)
235 // toTitle.String(k)
236
237 for k, v := range p {
238 // convert keys like "type" to "Type", "productName" to "ProductName" and e.t.c. when xml.
239 err = e.Encode(xmlMapEntry{XMLName: xml.Name{Local: strings.Title(k)}, Value: v})
240 if err != nil {
241 return err
242 }
243 }
244
245 return e.EncodeToken(start.End())
246}
247
248// DefaultProblemOptions the default options for `Context.Problem` method.
249var DefaultProblemOptions = ProblemOptions{

Callers

nothing calls this directly

Calls 2

EncodeMethod · 0.80
TitleMethod · 0.80

Tested by

no test coverage detected