mirror of
https://github.com/kataras/iris.git
synced 2025-12-21 20:07:04 +00:00
Version 3.0.0-beta cleaned
This commit is contained in:
23
bindings/xml.go
Normal file
23
bindings/xml.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package bindings
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/kataras/iris/context"
|
||||
)
|
||||
|
||||
// BindXML reads XML from request's body
|
||||
func BindXML(ctx context.IContext, xmlObject interface{}) error {
|
||||
data := ctx.GetRequestCtx().Request.Body()
|
||||
|
||||
decoder := xml.NewDecoder(strings.NewReader(string(data)))
|
||||
err := decoder.Decode(xmlObject)
|
||||
//err != nil fix by @shiena
|
||||
if err != nil && err != io.EOF {
|
||||
return ErrReadBody.Format("XML", err.Error())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user