mirror of
https://github.com/1f349/go-webdav.git
synced 2024-10-18 08:51:50 +01:00
6887b6b812
Currently, the user principal path and the home set path are both hardcoded to "/", for both CalDAV and CardDAV. This poses a challenge if one wishes to run a CardDAV and CalDAV server in the same server. This commit introduces the concept of a UserPrincipalBackend. This backend must provide the path of the current user's principal URL from the given request context. The CalDAV and CardDAV backends are extended to also function as UserPrincipalBackend. In addition, they are required to supply the path of the respective home set (`calendar-home-set` and `addressbook-home-set`). The CardDAV and CalDAV servers act accordingly. The individual servers will continue to work as before (including the option of keeping everything at "/"). If one wishes to run CardDAV and CalDAV in parallel, the new `webdav.ServeUserPrincipal()` can be used as a convenience function to serve a common user principal URL for both servers. The input for this function can be easily computed by the application by getting the home set paths from the backends and using `caldav.NewCalendarHomeSet()` and `carddav.NewAddressbookHomeSet()` to create the home sets. Note that the storage backend will have to know about these paths as well. For any non-trivial use case, a storage backend should probably have access to the same UserPrincipalBackend. That is, however, an implementation detail and doesn't have to be reflected in the interfaces.
79 lines
1.4 KiB
Go
79 lines
1.4 KiB
Go
// Package caldav provides a client and server CalDAV implementation.
|
|
//
|
|
// CalDAV is defined in RFC 4791.
|
|
package caldav
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/emersion/go-ical"
|
|
"github.com/emersion/go-webdav"
|
|
"github.com/emersion/go-webdav/internal"
|
|
)
|
|
|
|
func NewCalendarHomeSet(path string) webdav.BackendSuppliedHomeSet {
|
|
return &calendarHomeSet{Href: internal.Href{Path: path}}
|
|
}
|
|
|
|
type Calendar struct {
|
|
Path string
|
|
Name string
|
|
Description string
|
|
MaxResourceSize int64
|
|
SupportedComponentSet []string
|
|
}
|
|
|
|
type CalendarCompRequest struct {
|
|
Name string
|
|
|
|
AllProps bool
|
|
Props []string
|
|
|
|
AllComps bool
|
|
Comps []CalendarCompRequest
|
|
}
|
|
|
|
type CompFilter struct {
|
|
Name string
|
|
IsNotDefined bool
|
|
Start, End time.Time
|
|
Props []PropFilter
|
|
Comps []CompFilter
|
|
}
|
|
|
|
type ParamFilter struct {
|
|
Name string
|
|
IsNotDefined bool
|
|
TextMatch *TextMatch
|
|
}
|
|
|
|
type PropFilter struct {
|
|
Name string
|
|
IsNotDefined bool
|
|
Start, End time.Time
|
|
TextMatch *TextMatch
|
|
ParamFilter []ParamFilter
|
|
}
|
|
|
|
type TextMatch struct {
|
|
Text string
|
|
NegateCondition bool
|
|
}
|
|
|
|
type CalendarQuery struct {
|
|
CompRequest CalendarCompRequest
|
|
CompFilter CompFilter
|
|
}
|
|
|
|
type CalendarMultiGet struct {
|
|
Paths []string
|
|
CompRequest CalendarCompRequest
|
|
}
|
|
|
|
type CalendarObject struct {
|
|
Path string
|
|
ModTime time.Time
|
|
ETag string
|
|
Data *ical.Calendar
|
|
}
|