mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 16:24:14 +00:00
internal: add RawXMLValue.Decode
This commit is contained in:
parent
3beb076950
commit
6f9ff62747
@ -1,7 +1,6 @@
|
||||
package webdav
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
@ -55,7 +54,7 @@ func (c *Client) FindCurrentUserPrincipal() (string, error) {
|
||||
propstat := &resp.Propstats[0]
|
||||
|
||||
var prop currentUserPrincipalProp
|
||||
if err := xml.NewTokenDecoder(propstat.Prop.TokenReader()).Decode(&prop); err != nil {
|
||||
if err := propstat.Prop.Decode(&prop); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,10 @@ func (val *RawXMLValue) MarshalXML(e *xml.Encoder, start xml.StartElement) error
|
||||
var _ xml.Marshaler = (*RawXMLValue)(nil)
|
||||
var _ xml.Unmarshaler = (*RawXMLValue)(nil)
|
||||
|
||||
func (val *RawXMLValue) Decode(v interface{}) error {
|
||||
return xml.NewTokenDecoder(val.TokenReader()).Decode(&v)
|
||||
}
|
||||
|
||||
// TokenReader returns a stream of tokens for the XML value.
|
||||
func (val *RawXMLValue) TokenReader() xml.TokenReader {
|
||||
return &rawXMLValueReader{val: val}
|
||||
|
Loading…
Reference in New Issue
Block a user