go-webdav/internal/elements.go
2020-01-14 20:27:08 +01:00

48 lines
1.5 KiB
Go

package internal
import (
"encoding/xml"
)
// https://tools.ietf.org/html/rfc4918#section-14.16
type multistatus struct {
XMLName xml.Name `xml:"DAV: multistatus"`
Responses []Response `xml:"DAV: response"`
ResponseDescription string `xml:"DAV: responsedescription,omitempty"`
}
// https://tools.ietf.org/html/rfc4918#section-14.24
type Response struct {
XMLName xml.Name `xml:"DAV: response"`
Href string `xml:"DAV: href"`
Propstats []Propstat `xml:"DAV: propstat"`
ResponseDescription string `xml:"DAV: responsedescription,omitempty"`
// TODO: (href*, status)
// TODO: error?, location?
}
// https://tools.ietf.org/html/rfc4918#section-14.22
type Propstat struct {
XMLName xml.Name `xml:"DAV: propstat"`
Prop RawXMLValue `xml:"DAV: prop"`
Status string `xml:"DAV: status"`
ResponseDescription string `xml:"DAV: responsedescription,omitempty"`
// TODO: error?
}
// https://tools.ietf.org/html/rfc4918#section-14.20
type Propfind struct {
XMLName xml.Name `xml:"DAV: propfind"`
Prop *RawXMLValue `xml:"DAV: prop,omitempty"`
// TODO: propname | (allprop, include?)
}
func NewPropPropfind(names ...xml.Name) *Propfind {
children := make([]RawXMLValue, len(names))
for i, name := range names {
children[i] = *NewRawXMLElement(name, nil, nil)
}
prop := NewRawXMLElement(xml.Name{"DAV:", "prop"}, nil, children)
return &Propfind{Prop: prop}
}