This repository was archived by the owner on Feb 9, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -208,6 +208,30 @@ func Handler(ctx *volta.Ctx) error {
208
208
` ` `
209
209
{% endcode %}
210
210
211
+ ## ReplyXML
212
+
213
+ Function to reply to a message with automatically xml marshal.
214
+
215
+ body: interface {} - The message body to reply with.
216
+
217
+ {% code title=" Signature" lineNumbers=" true" %}
218
+ ` ` ` go
219
+ func (ctx *Ctx) ReplyXML(body interface{}) error
220
+ ` ` `
221
+ {% endcode %}
222
+
223
+ {% code title=" Example" lineNumbers=" true" %}
224
+ ` ` ` go
225
+ type User struct {
226
+ Name string ` xml:" name" `
227
+ }
228
+
229
+ func Handler(ctx *volta.Ctx) error {
230
+ return ctx.ReplyXML(&User{Name: "John"})
231
+ }
232
+ ` ` `
233
+ {% endcode %}
234
+
211
235
## ContentType
212
236
213
237
Function to get the message content type .
Original file line number Diff line number Diff line change @@ -45,6 +45,15 @@ func (ctx *Ctx) ReplyJSON(data interface{}) error {
45
45
return ctx .Reply (jsonData )
46
46
}
47
47
48
+ func (ctx * Ctx ) ReplyXML (data interface {}) error {
49
+ xmlData , err := xml .Marshal (data )
50
+ if err != nil {
51
+ return err
52
+ }
53
+
54
+ return ctx .Reply (xmlData )
55
+ }
56
+
48
57
func (ctx * Ctx ) Next () error {
49
58
ctx .handlerCursor ++
50
59
if ctx .handlerCursor < len (ctx .handlers ) {
You can’t perform that action at this time.
0 commit comments