Documentation
¶
Overview ¶
Package internal provides low-level helpers for WebDAV clients and servers.
Index ¶
- Constants
- Variables
- func DecodeXMLRequest(r *http.Request, v interface{}) error
- func DiscoverContextURL(ctx context.Context, service, domain string) (string, error)
- func FormatOverwrite(overwrite bool) string
- func IsNotFound(err error) bool
- func IsRequestBodyEmpty(r *http.Request) bool
- func ParseOverwrite(s string) (bool, error)
- func ServeError(w http.ResponseWriter, err error)
- func ServeMultiStatus(w http.ResponseWriter, ms *MultiStatus) error
- func ServeXML(w http.ResponseWriter) *xml.Encoder
- type Backend
- type Client
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) DoMultiStatus(req *http.Request) (*MultiStatus, error)
- func (c *Client) NewRequest(method string, path string, body io.Reader) (*http.Request, error)
- func (c *Client) NewXMLRequest(method string, path string, v interface{}) (*http.Request, error)
- func (c *Client) Options(ctx context.Context, path string) (classes map[string]bool, methods map[string]bool, err error)
- func (c *Client) PropFind(ctx context.Context, path string, depth Depth, propfind *PropFind) (*MultiStatus, error)
- func (c *Client) PropFindFlat(ctx context.Context, path string, propfind *PropFind) (*Response, error)
- func (c *Client) ResolveHref(p string) *url.URL
- func (c *Client) SyncCollection(ctx context.Context, path, syncToken string, level Depth, limit *Limit, ...) (*MultiStatus, error)
- type CurrentUserPrincipal
- type CurrentUserPrivilegeSet
- type Depth
- type DisplayName
- type ETag
- type Error
- type GetContentLength
- type GetContentType
- type GetETag
- type GetLastModified
- type HTTPClient
- type HTTPError
- type Handler
- type Href
- type Include
- type Limit
- type Location
- type MultiStatus
- type Privilege
- type Prop
- type PropFind
- type PropFindFunc
- type PropStat
- type PropertyUpdate
- type RawXMLValue
- func (val *RawXMLValue) Decode(v interface{}) error
- func (val *RawXMLValue) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (val *RawXMLValue) TokenReader() xml.TokenReader
- func (val *RawXMLValue) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (val *RawXMLValue) XMLName() (name xml.Name, ok bool)
- type Remove
- type ResourceType
- type Response
- type Set
- type Status
- type SyncCollectionQuery
- type Time
Constants ¶
const Namespace = "DAV:"
Variables ¶
var ( ResourceTypeName = xml.Name{Namespace, "resourcetype"} DisplayNameName = xml.Name{Namespace, "displayname"} GetContentLengthName = xml.Name{Namespace, "getcontentlength"} GetContentTypeName = xml.Name{Namespace, "getcontenttype"} GetLastModifiedName = xml.Name{Namespace, "getlastmodified"} GetETagName = xml.Name{Namespace, "getetag"} CollectionName = xml.Name{Namespace, "collection"} PrincipalName = xml.Name{Namespace, "principal"} CurrentUserPrincipalName = xml.Name{Namespace, "current-user-principal"} CurrentUserPrivilegeSetName = xml.Name{Namespace, "current-user-privilege-set"} )
Functions ¶
func DecodeXMLRequest ¶
func DiscoverContextURL ¶ added in v0.5.0
DiscoverContextURL performs a DNS-based CardDAV/CalDAV service discovery as described in RFC 6764. It returns the URL to the CardDAV/CalDAV server. Specifically it implements points 2 and 3 from the bootstrapping procedure defined in RFC 6764 section 6.
func FormatOverwrite ¶
FormatOverwrite formats an Overwrite header.
func IsNotFound ¶
func IsRequestBodyEmpty ¶ added in v0.6.0
func ParseOverwrite ¶
ParseOverwrite parses an Overwrite header.
func ServeError ¶
func ServeError(w http.ResponseWriter, err error)
func ServeMultiStatus ¶ added in v0.4.0
func ServeMultiStatus(w http.ResponseWriter, ms *MultiStatus) error
Types ¶
type Backend ¶
type Backend interface {
Options(r *http.Request) (caps []string, allow []string, err error)
HeadGet(w http.ResponseWriter, r *http.Request) error
PropFind(r *http.Request, pf *PropFind, depth Depth) (*MultiStatus, error)
PropPatch(r *http.Request, pu *PropertyUpdate) (*Response, error)
Put(w http.ResponseWriter, r *http.Request) error
Delete(r *http.Request) error
Mkcol(r *http.Request) error
Copy(r *http.Request, dest *Href, recursive, overwrite bool) (created bool, err error)
Move(r *http.Request, dest *Href, overwrite bool) (created bool, err error)
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) DoMultiStatus ¶
func (c *Client) DoMultiStatus(req *http.Request) (*MultiStatus, error)
func (*Client) NewRequest ¶
func (*Client) NewXMLRequest ¶
type CurrentUserPrincipal ¶
type CurrentUserPrivilegeSet ¶ added in v0.7.0
type Depth ¶
type Depth int
Depth indicates whether a request applies to the resource's members. It's defined in RFC 4918 section 10.2.
const ( // DepthZero indicates that the request applies only to the resource. DepthZero Depth = 0 // DepthOne indicates that the request applies to the resource and its // internal members only. DepthOne Depth = 1 // DepthInfinity indicates that the request applies to the resource and all // of its members. DepthInfinity Depth = -1 )
type DisplayName ¶
type ETag ¶ added in v0.3.0
type ETag string
func (ETag) MarshalText ¶ added in v0.3.0
func (*ETag) UnmarshalText ¶ added in v0.3.0
type Error ¶
type Error struct {
XMLName xml.Name `xml:"DAV: error"`
Raw []RawXMLValue `xml:",any"`
}
type GetContentLength ¶
type GetContentType ¶
type GetLastModified ¶
type HTTPClient ¶ added in v0.3.0
HTTPClient performs HTTP requests. It's implemented by *http.Client.
type Include ¶
type Include struct {
XMLName xml.Name `xml:"DAV: include"`
Raw []RawXMLValue `xml:",any"`
}
type MultiStatus ¶ added in v0.4.0
type MultiStatus struct {
XMLName xml.Name `xml:"DAV: multistatus"`
Responses []Response `xml:"response"`
ResponseDescription string `xml:"responsedescription,omitempty"`
SyncToken string `xml:"sync-token,omitempty"`
}
https://tools.ietf.org/html/rfc4918#section-14.16
func NewMultiStatus ¶ added in v0.4.0
func NewMultiStatus(resps ...Response) *MultiStatus
type Privilege ¶ added in v0.7.0
type Prop ¶
type Prop struct {
XMLName xml.Name `xml:"DAV: prop"`
Raw []RawXMLValue `xml:",any"`
}
https://tools.ietf.org/html/rfc4918#section-14.18
func EncodeProp ¶
type PropFind ¶ added in v0.4.0
type PropFind struct {
XMLName xml.Name `xml:"DAV: propfind"`
Prop *Prop `xml:"prop,omitempty"`
AllProp *struct{} `xml:"allprop,omitempty"`
Include *Include `xml:"include,omitempty"`
PropName *struct{} `xml:"propname,omitempty"`
}
https://tools.ietf.org/html/rfc4918#section-14.20
func NewPropNamePropFind ¶ added in v0.4.0
type PropFindFunc ¶ added in v0.4.0
type PropFindFunc func(raw *RawXMLValue) (interface{}, error)
func PropFindValue ¶ added in v0.7.0
func PropFindValue(value interface{}) PropFindFunc
type PropStat ¶ added in v0.4.0
type PropertyUpdate ¶ added in v0.4.0
type RawXMLValue ¶
type RawXMLValue struct {
// contains filtered or unexported fields
}
RawXMLValue is a raw XML value. It implements xml.Unmarshaler and xml.Marshaler and can be used to delay XML decoding or precompute an XML encoding.
func EncodeRawXMLElement ¶
func EncodeRawXMLElement(v interface{}) (*RawXMLValue, error)
EncodeRawXMLElement encodes a value into a new RawXMLValue. The XML value can only be used for marshalling.
func NewRawXMLElement ¶
func NewRawXMLElement(name xml.Name, attr []xml.Attr, children []RawXMLValue) *RawXMLValue
NewRawXMLElement creates a new RawXMLValue for an element.
func (*RawXMLValue) Decode ¶
func (val *RawXMLValue) Decode(v interface{}) error
func (*RawXMLValue) MarshalXML ¶
func (val *RawXMLValue) MarshalXML(e *xml.Encoder, start xml.StartElement) error
MarshalXML implements xml.Marshaler.
func (*RawXMLValue) TokenReader ¶
func (val *RawXMLValue) TokenReader() xml.TokenReader
TokenReader returns a stream of tokens for the XML value.
func (*RawXMLValue) UnmarshalXML ¶
func (val *RawXMLValue) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML implements xml.Unmarshaler.
type ResourceType ¶
type ResourceType struct {
XMLName xml.Name `xml:"DAV: resourcetype"`
Raw []RawXMLValue `xml:",any"`
}
https://tools.ietf.org/html/rfc4918#section-15.9
func NewResourceType ¶
func NewResourceType(names ...xml.Name) *ResourceType
type Response ¶
type Response struct {
XMLName xml.Name `xml:"DAV: response"`
Hrefs []Href `xml:"href"`
PropStats []PropStat `xml:"propstat,omitempty"`
ResponseDescription string `xml:"responsedescription,omitempty"`
Status *Status `xml:"status,omitempty"`
Error *Error `xml:"error,omitempty"`
Location *Location `xml:"location,omitempty"`
}
https://tools.ietf.org/html/rfc4918#section-14.24