2019-05-30 23:11:13 +01:00
|
|
|
package xml
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/xml"
|
|
|
|
|
2020-08-19 17:47:17 +03:00
|
|
|
"github.com/unistack-org/micro/v3/config/encoder"
|
2019-05-30 23:11:13 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
type xmlEncoder struct{}
|
|
|
|
|
|
|
|
func (x xmlEncoder) Encode(v interface{}) ([]byte, error) {
|
|
|
|
return xml.Marshal(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x xmlEncoder) Decode(d []byte, v interface{}) error {
|
|
|
|
return xml.Unmarshal(d, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x xmlEncoder) String() string {
|
|
|
|
return "xml"
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewEncoder() encoder.Encoder {
|
|
|
|
return xmlEncoder{}
|
|
|
|
}
|