Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CaldavHandler ¶
type CaldavHandler struct {
Prefix string // e.g., "/caldav/"
Realm string // Realm for Basic Auth
Storage storage.Storage
MaxDepth int // Optional: Max depth for PROPFIND requests, >3 for infinity
URLConverter URLConverter
Logger *slog.Logger // Logger for structured logging
}
CaldavHandler is the main HTTP handler for CalDAV requests under a specific prefix.
func NewCaldavHandler ¶
func NewCaldavHandler(prefix, realm string, storage storage.Storage, maxDepth int, converter URLConverter, logger *slog.Logger) *CaldavHandler
NewCaldavHandler creates a new CaldavHandler.
func (*CaldavHandler) ServeHTTP ¶
func (h *CaldavHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP handles incoming HTTP requests, performs authentication, parsing, and routing.
func (*CaldavHandler) ServeWellKnown ¶
func (h *CaldavHandler) ServeWellKnown(w http.ResponseWriter, r *http.Request)
ServeWellKnown handles requests to the well-known CalDAV URL.
type RequestContext ¶
type RequestContext struct {
Resource Resource // Contains UserID, CalendarID, ObjectID, and ResourceType
AuthUser string // Authenticated user (from Basic Auth)
Depth int // >3 is the same as infinity
}
RequestContext holds parsed information about the incoming CalDAV request.
type URLConverter ¶
type URLConverter interface {
// ParsePath parses a given path and returns the corresponding Resource.
ParsePath(path string) (Resource, error)
// EncodePath encodes a Resource back to its URL path representation.
EncodePath(resource Resource) (string, error)
}
URLConverter helps you define URL path convention. Leave this blank when creating handler defaults to defaultURLConverter.
However, there are some basic assumptions you should respect:
A resource should be able to find its parent from its path. For example, /<userid>/cal/<calendarid>/<objectid> belongs to user <userid> and calendar <calendarid>. Please consider including all those information in your URI, or you might encounter excessive overhead looking for parent resources.
If you set prefix in the handler, you should consider initializing your URLConverter with the same prefix, like defaultURLConverter does.