libdav package - code.pfad.fr/gopim/webdav
import "code.pfad.fr/gopim/webdav/libdav"
Functions
func ContextWith
func ContextWith(ctx context.Context, name property.Responder, resp func(p property.Responder) (interface{}, error)) context.Context
func ContextWithCurrentUserPrincipal
func ContextWithCurrentUserPrincipal(ctx context.Context, cup func(p property.Responder) (interface{}, error)) context.Context
func DecodeXMLRequest
func DecodeXMLRequest[T any](r *http.Request, decode func(http.Header, *xml.Decoder) (T, error)) (v T, err error)
decode may be called with an empty body
Types
type Depth
rfc4918#section-10.2 Depth Header
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
)
func DecodeDepth
func DecodeDepth(header http.Header) (Depth, error)
DecodeDepth decodes the Depth header.
func (Depth) String
func (d Depth) String() string
String formats the depth.
type Get
type Get struct {
Request *http.Request
ResponseWriter http.ResponseWriter
}
func (Get) ServeContent
func (g Get) ServeContent(contentType string, etagQuoted string, modtime time.Time, content io.ReadSeeker)
func (Get) ServeList
func (g Get) ServeList(names []string, modTime time.Time) error
ServeList serves an HTML list of the names. The list MUST be sorted.
type HTTPError
type HTTPError interface {
error
StatusCode() int
}
func NewHTTPError
func NewHTTPError(code int, err error) HTTPError
if err is nil, the standard status text is used
type HandleWriter
type HandleWriter interface {
Handler
Delete(req Request) error // recursive delete
// rfc4918#section-9.7
Put(req Request,
header http.Header,
body io.ReadCloser,
) (statusCode int, headers http.Header, err error)
}
type Handler
type Handler interface {
Options(req Request) (caps []string, methods []string, err error)
Get(req Request, get Get) error
Propfind(req Request, propfind Propfind) ([]Response, error)
Report(req Request, report Report) ([]Response, error)
}
type MultiStatus
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]
https://tools.ietf.org/html/rfc4918#section-14.16
func NewMultiStatus
func NewMultiStatus(resps ...Response) MultiStatus
type Overwrite
rfc4918#section-10.6 Overwrite Header
func DecodeOverwrite
func DecodeOverwrite(header http.Header) (Overwrite, error)
DecodeOverwrite decodes the Overwrite header.
func (Overwrite) String
func (o Overwrite) String() string
String formats the overwrite.
type PrincipalHandler
type PrincipalHandler struct {
StatusHandler
AddressbookHomeSet string
}
func (PrincipalHandler) Options
func (p PrincipalHandler) Options(req Request) (caps []string, methods []string, err error)
Options implements Handler.
func (PrincipalHandler) Propfind
func (ph PrincipalHandler) Propfind(req Request, propfind Propfind) ([]Response, error)
Propfind implements Handler.
type PropStat
type PropStat struct {
Prop PropsRequest
Allprop bool
Propname bool
// Include indicates additional props when Allprop is set
Include []xml.Name
}
func (PropStat) Response
func (ps PropStat) Response(ctx context.Context, path string, props property.ResponseMap) Response
if props is nil a not-found (404) response will be returned
func (PropStat) Validate
func (ps PropStat) Validate() error
type Propfind
type Propfind struct {
PropStat PropStat
Depth Depth
}
rfc4918#section-14.20 only Prop, Allprop XOR Propname will be set
func DecodePropfind
func DecodePropfind(header http.Header, dec *xml.Decoder) (Propfind, error)
func (Propfind) Response
func (pf Propfind) Response(ctx context.Context, path string, props property.ResponseMap) Response
type PropsRequest
type PropsRequest []struct {
XMLName xml.Name
SubProps []struct {
XMLName xml.Name
Name string `xml:"name,attr"`
} `xml:",any"`
}
func (PropsRequest) Names
func (pr PropsRequest) Names() []xml.Name
func (PropsRequest) SubnameAttr
func (pr PropsRequest) SubnameAttr(parent, child xml.Name) []string
SubnameAttr return nil if the parent is not present, otherwise it might return an empty slice.
type Propstat
type Propstat struct {
Prop []any `xml:"prop>any"`
Status ResponseStatus `xml:"status"`
Responsedescription string `xml:"responsedescription,omitempty"`
Error any `xml:"error,omitempty"`
}
[https://tools.ietf.org/html/rfc4918#section-14.22]
https://tools.ietf.org/html/rfc4918#section-14.22
type Report
type Report struct {
Unmarshal func(m map[xml.Name]any) (xml.Name, error)
Depth Depth
}
func DecodeReport
func DecodeReport(header http.Header, dec *xml.Decoder) (Report, error)
type Request
type Request struct {
Context context.Context
Segments []string
SegmentTrailingSlash bool
Resource Resource
}
func (Request) Children
func (r Request) Children() iter.Seq[Request]
func (Request) Path
func (r Request) Path() string
func (Request) Segment
func (r Request) Segment(i int) string
Segment returns the i-th element, accepting negative values (-1 to get the last element).
type Resource
type Resource struct {
Handler Handler
Children map[string]Resource
CatchAll *Resource
IsLeaf bool // true if not a collection
}
type Response
type Response struct {
Href property.Href `xml:"href"`
Propstats []Propstat `xml:"propstat,omitempty"`
Responsedescription string `xml:"responsedescription,omitempty"`
Status *ResponseStatus `xml:"status,omitempty"`
Error any `xml:"error,omitempty"`
Location *property.Href `xml:"location>href,omitempty"`
}
[https://tools.ietf.org/html/rfc4918#section-14.24]
https://tools.ietf.org/html/rfc4918#section-14.24
type ResponseStatus
type ResponseStatus struct {
Code int // will default to 200 if left empty
Text string // will be the default http status text for the code if left empty
}
rfc4918#section-14.28 rfc2616#section-6.1
func (ResponseStatus) MarshalText
func (s ResponseStatus) MarshalText() ([]byte, error)
func (*ResponseStatus) UnmarshalText
func (s *ResponseStatus) UnmarshalText(b []byte) error
type StaticHandler
type StaticHandler struct {
StatusHandler
Caps []string
Properties property.ResponseMap
}
func (StaticHandler) Options
func (p StaticHandler) Options(req Request) (caps []string, methods []string, err error)
Options implements Handler.
func (StaticHandler) Propfind
func (p StaticHandler) Propfind(req Request, propfind Propfind) ([]Response, error)
Propfind implements Handler.
type StatusHandler
type StatusHandler struct {
Code int
}
func (StatusHandler) Delete
func (p StatusHandler) Delete(req Request) error
Delete implements HandleWriter.
func (StatusHandler) Get
func (p StatusHandler) Get(req Request, get Get) error
Get implements Handler.
func (StatusHandler) Options
func (p StatusHandler) Options(req Request) (caps []string, methods []string, err error)
Options implements Handler.
func (StatusHandler) Propfind
func (p StatusHandler) Propfind(req Request, propfind Propfind) ([]Response, error)
Propfind implements Handler.
func (StatusHandler) Put
func (p StatusHandler) Put(req Request, header http.Header, body io.ReadCloser) (statusCode int, headers http.Header, err error)
Put implements HandleWriter.
func (StatusHandler) Report
func (p StatusHandler) Report(req Request, report Report) ([]Response, error)
Report implements Handler.
Files
error.go
get.go
headers.go
propfind.go
report.go
request.go
resource.go
response.go
Directories
internal
Breadcrumb
code.pfad.fr/gopim/webdav