Documentation
¶
Index ¶
- Constants
- func BasicAuthMiddleware(userRepo repository.UserRepository, logger *zap.Logger) func(http.Handler) http.Handler
- func FormatHTTPDate(t time.Time) string
- func FormatISO8601(t time.Time) string
- func GetUserID(r *http.Request) (int64, bool)
- func GetUserIDFromContext(ctx context.Context) (int64, bool)
- func GetUsernameFromContext(ctx context.Context) (string, bool)
- type AddressDataRequest
- type AddressDataType
- type CalendarComponent
- type CalendarDataRequest
- type Config
- type Error
- type FileSystemStorage
- func (s *FileSystemStorage) CopyResource(src, dst string, overwrite bool) error
- func (s *FileSystemStorage) CreateCollection(path string) error
- func (s *FileSystemStorage) DeleteResource(path string) error
- func (s *FileSystemStorage) Exists(path string) bool
- func (s *FileSystemStorage) GetResourceInfo(path string) (*ResourceInfo, error)
- func (s *FileSystemStorage) ListChildren(path string) ([]*ResourceInfo, error)
- func (s *FileSystemStorage) MoveResource(src, dst string, overwrite bool) error
- func (s *FileSystemStorage) ReadResource(path string) (io.ReadCloser, error)
- func (s *FileSystemStorage) WriteResource(path string, content io.Reader) error
- type Handler
- type Href
- type MultiStatus
- type Prop
- type PropFind
- type PropStat
- type PropValue
- type PropertyUpdate
- type Remove
- type ResourceInfo
- type ResourceType
- type Response
- type Server
- type Set
- type Storage
- type SupportedAddressData
- type SupportedCalendarComponentSet
Constants ¶
const ( UserIDKey contextKey = "user_id" UsernameKey contextKey = "username" UserEmailKey contextKey = "user_email" )
Variables ¶
This section is empty.
Functions ¶
func BasicAuthMiddleware ¶
func BasicAuthMiddleware(userRepo repository.UserRepository, logger *zap.Logger) func(http.Handler) http.Handler
BasicAuthMiddleware provides HTTP Basic Authentication for WebDAV endpoints
func FormatHTTPDate ¶
FormatHTTPDate formats a time for HTTP headers (RFC 1123)
func FormatISO8601 ¶
FormatISO8601 formats a time in ISO 8601 format
func GetUserIDFromContext ¶
GetUserIDFromContext extracts user ID from context
Types ¶
type AddressDataRequest ¶
type AddressDataRequest struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:carddav address-data"`
}
AddressDataRequest represents an address-data property request
type AddressDataType ¶
type AddressDataType struct {
ContentType string `xml:"content-type,attr"`
Version string `xml:"version,attr"`
}
AddressDataType represents a supported vCard format
type CalendarComponent ¶
type CalendarComponent struct {
Name string `xml:"name,attr"`
}
CalendarComponent represents a calendar component type
type CalendarDataRequest ¶
type CalendarDataRequest struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav calendar-data"`
}
CalendarDataRequest represents a calendar-data property request
type FileSystemStorage ¶
type FileSystemStorage struct {
// contains filtered or unexported fields
}
FileSystemStorage implements Storage using the local filesystem
func NewFileSystemStorage ¶
func NewFileSystemStorage(basePath string, logger *zap.Logger) *FileSystemStorage
NewFileSystemStorage creates a new filesystem-based storage
func (*FileSystemStorage) CopyResource ¶
func (s *FileSystemStorage) CopyResource(src, dst string, overwrite bool) error
CopyResource copies a resource to a new location
func (*FileSystemStorage) CreateCollection ¶
func (s *FileSystemStorage) CreateCollection(path string) error
CreateCollection creates a new collection (directory)
func (*FileSystemStorage) DeleteResource ¶
func (s *FileSystemStorage) DeleteResource(path string) error
DeleteResource deletes a resource or collection
func (*FileSystemStorage) Exists ¶
func (s *FileSystemStorage) Exists(path string) bool
Exists checks if a resource exists
func (*FileSystemStorage) GetResourceInfo ¶
func (s *FileSystemStorage) GetResourceInfo(path string) (*ResourceInfo, error)
GetResourceInfo retrieves metadata for a resource
func (*FileSystemStorage) ListChildren ¶
func (s *FileSystemStorage) ListChildren(path string) ([]*ResourceInfo, error)
ListChildren returns children of a collection
func (*FileSystemStorage) MoveResource ¶
func (s *FileSystemStorage) MoveResource(src, dst string, overwrite bool) error
MoveResource moves a resource to a new location
func (*FileSystemStorage) ReadResource ¶
func (s *FileSystemStorage) ReadResource(path string) (io.ReadCloser, error)
ReadResource reads the content of a resource
func (*FileSystemStorage) WriteResource ¶
func (s *FileSystemStorage) WriteResource(path string, content io.Reader) error
WriteResource writes content to a resource
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements WebDAV HTTP methods
func NewHandler ¶
NewHandler creates a new WebDAV handler
func NewHandlerWithStorage ¶
NewHandlerWithStorage creates a new WebDAV handler with storage backend
func (*Handler) ServeHTTP ¶
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler interface
func (*Handler) SetStorage ¶
SetStorage sets the storage backend
type MultiStatus ¶
type MultiStatus struct {
XMLName xml.Name `xml:"DAV: multistatus"`
Responses []Response `xml:"response"`
SyncToken string `xml:"sync-token,omitempty"`
}
MultiStatus represents a WebDAV multistatus response
type Prop ¶
type Prop struct {
ResourceType *struct{} `xml:"DAV: resourcetype"`
DisplayName *struct{} `xml:"DAV: displayname"`
GetContentType *struct{} `xml:"DAV: getcontenttype"`
GetETag *struct{} `xml:"DAV: getetag"`
GetLastModified *struct{} `xml:"DAV: getlastmodified"`
GetContentLength *struct{} `xml:"DAV: getcontentlength"`
CreationDate *struct{} `xml:"DAV: creationdate"`
CurrentUserPrincipal *struct{} `xml:"DAV: current-user-principal"`
// CalDAV specific
CalendarData *CalendarDataRequest `xml:"urn:ietf:params:xml:ns:caldav calendar-data"`
CalendarHomeSet *struct{} `xml:"urn:ietf:params:xml:ns:caldav calendar-home-set"`
CalendarDescription *struct{} `xml:"urn:ietf:params:xml:ns:caldav calendar-description"`
CalendarColor *struct{} `xml:"http://apple.com/ns/ical/ calendar-color"`
CalendarOrder *struct{} `xml:"http://apple.com/ns/ical/ calendar-order"`
SupportedCalendarComponentSet *struct{} `xml:"urn:ietf:params:xml:ns:caldav supported-calendar-component-set"`
// CardDAV specific
AddressData *AddressDataRequest `xml:"urn:ietf:params:xml:ns:carddav address-data"`
AddressbookHomeSet *struct{} `xml:"urn:ietf:params:xml:ns:carddav addressbook-home-set"`
AddressbookDescription *struct{} `xml:"urn:ietf:params:xml:ns:carddav addressbook-description"`
SupportedAddressData *struct{} `xml:"urn:ietf:params:xml:ns:carddav supported-address-data"`
}
Prop represents requested properties
type PropFind ¶
type PropFind struct {
XMLName xml.Name `xml:"DAV: propfind"`
AllProp *struct{} `xml:"allprop"`
PropName *struct{} `xml:"propname"`
Prop *Prop `xml:"prop"`
}
PropFind represents a PROPFIND request
type PropValue ¶
type PropValue struct {
ResourceType *ResourceType `xml:"DAV: resourcetype,omitempty"`
DisplayName *string `xml:"DAV: displayname,omitempty"`
GetContentType *string `xml:"DAV: getcontenttype,omitempty"`
GetETag *string `xml:"DAV: getetag,omitempty"`
GetLastModified *string `xml:"DAV: getlastmodified,omitempty"`
GetContentLength *int64 `xml:"DAV: getcontentlength,omitempty"`
CreationDate *string `xml:"DAV: creationdate,omitempty"`
CurrentUserPrincipal *Href `xml:"DAV: current-user-principal,omitempty"`
// CalDAV specific
CalendarData *string `xml:"urn:ietf:params:xml:ns:caldav calendar-data,omitempty"`
CalendarHomeSet *Href `xml:"urn:ietf:params:xml:ns:caldav calendar-home-set,omitempty"`
CalendarDescription *string `xml:"urn:ietf:params:xml:ns:caldav calendar-description,omitempty"`
CalendarColor *string `xml:"http://apple.com/ns/ical/ calendar-color,omitempty"`
CalendarOrder *int `xml:"http://apple.com/ns/ical/ calendar-order,omitempty"`
SupportedCalendarComponentSet *SupportedCalendarComponentSet `xml:"urn:ietf:params:xml:ns:caldav supported-calendar-component-set,omitempty"`
// CardDAV specific
AddressData *string `xml:"urn:ietf:params:xml:ns:carddav address-data,omitempty"`
AddressbookHomeSet *Href `xml:"urn:ietf:params:xml:ns:carddav addressbook-home-set,omitempty"`
AddressbookDescription *string `xml:"urn:ietf:params:xml:ns:carddav addressbook-description,omitempty"`
SupportedAddressData *SupportedAddressData `xml:"urn:ietf:params:xml:ns:carddav supported-address-data,omitempty"`
}
PropValue represents property values in a response
type PropertyUpdate ¶
type ResourceInfo ¶
type ResourceInfo struct {
Path string
Name string
IsCollection bool
ContentType string
ContentLen int64
ETag string
ModTime time.Time
CreateTime time.Time
ResourceKind string // "collection", "calendar", "addressbook", "principal", "event", "contact", "file"
}
ResourceInfo contains metadata about a WebDAV resource
type ResourceType ¶
type ResourceType struct {
Collection *struct{} `xml:"DAV: collection,omitempty"`
Calendar *struct{} `xml:"urn:ietf:params:xml:ns:caldav calendar,omitempty"`
Addressbook *struct{} `xml:"urn:ietf:params:xml:ns:carddav addressbook,omitempty"`
Principal *struct{} `xml:"DAV: principal,omitempty"`
}
ResourceType represents the type of a WebDAV resource
type Response ¶
type Response struct {
Href string `xml:"href"`
PropStats []PropStat `xml:"propstat"`
Status string `xml:"status,omitempty"`
Error *Error `xml:"error,omitempty"`
}
Response represents a single resource response
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the WebDAV HTTP server
func NewServer ¶
func NewServer(cfg *Config, caldavHandler, carddavHandler http.Handler, userRepo repository.UserRepository, logger *zap.Logger) *Server
NewServer creates a new WebDAV server with CalDAV and CardDAV handlers
type Storage ¶
type Storage interface {
// GetResourceInfo retrieves metadata for a resource
GetResourceInfo(path string) (*ResourceInfo, error)
// ListChildren returns children of a collection
ListChildren(path string) ([]*ResourceInfo, error)
// CreateCollection creates a new collection (directory)
CreateCollection(path string) error
// DeleteResource deletes a resource or collection
DeleteResource(path string) error
// CopyResource copies a resource to a new location
CopyResource(src, dst string, overwrite bool) error
// MoveResource moves a resource to a new location
MoveResource(src, dst string, overwrite bool) error
// ReadResource reads the content of a resource
ReadResource(path string) (io.ReadCloser, error)
// WriteResource writes content to a resource
WriteResource(path string, content io.Reader) error
// Exists checks if a resource exists
Exists(path string) bool
}
Storage defines the interface for WebDAV resource storage
type SupportedAddressData ¶
type SupportedAddressData struct {
AddressDataTypes []AddressDataType `xml:"address-data-type"`
}
SupportedAddressData represents supported address data formats
type SupportedCalendarComponentSet ¶
type SupportedCalendarComponentSet struct {
Components []CalendarComponent `xml:"comp"`
}
SupportedCalendarComponentSet represents supported calendar component types