mirror of
https://github.com/go-kratos/kratos.git
synced 2025-02-03 13:11:42 +02:00
23 lines
367 B
Go
23 lines
367 B
Go
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)
|
|
}
|