You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
367 B
23 lines
367 B
6 years ago
|
package binding
|
||
|
|
||
|
import (
|
||
|
"encoding/xml"
|
||
|
"net/http"
|
||
|
|
||
|
"github.com/pkg/errors"
|
||
|
)
|
||
|
|
||
|
type xmlBinding struct{}
|
||
|
|
||
|
func (xmlBinding) Name() string {
|
||
|
return "xml"
|
||
|
}
|
||
|
|
||
|
func (xmlBinding) Bind(req *http.Request, obj interface{}) error {
|
||
|
decoder := xml.NewDecoder(req.Body)
|
||
|
if err := decoder.Decode(obj); err != nil {
|
||
|
return errors.WithStack(err)
|
||
|
}
|
||
|
return validate(obj)
|
||
|
}
|