Version: v0.3.1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2021 License: MIT Imports: 13 Imported by: 7



Package carddav provides a client and server CardDAV implementation.

CardDAV is defined in RFC 6352.



This section is empty.


This section is empty.


func Discover added in v0.2.0

func Discover(domain string) (string, error)

Discover performs a DNS-based CardDAV service discovery as described in RFC 6352 section 11. It returns the URL to the CardDAV server.


type AddressBook

type AddressBook struct {
	Path                 string
	Name                 string
	Description          string
	MaxResourceSize      int64
	SupportedAddressData []AddressDataType

func (*AddressBook) SupportsAddressData added in v0.3.0

func (ab *AddressBook) SupportsAddressData(contentType, version string) bool

type AddressBookMultiGet added in v0.2.0

type AddressBookMultiGet struct {
	Paths       []string
	DataRequest AddressDataRequest

type AddressBookQuery added in v0.2.0

type AddressBookQuery struct {
	DataRequest AddressDataRequest

	PropFilters []PropFilter
	FilterTest  FilterTest // defaults to FilterAnyOf

	Limit int // <= 0 means unlimited

type AddressDataRequest added in v0.2.0

type AddressDataRequest struct {
	Props   []string
	AllProp bool

type AddressDataType added in v0.3.0

type AddressDataType struct {
	ContentType string
	Version     string

type AddressObject

type AddressObject struct {
	Path    string
	ModTime time.Time
	ETag    string
	Card    vcard.Card

type Backend added in v0.2.0

type Backend interface {
	AddressBook() (*AddressBook, error)
	GetAddressObject(path string, req *AddressDataRequest) (*AddressObject, error)
	ListAddressObjects(req *AddressDataRequest) ([]AddressObject, error)
	QueryAddressObjects(query *AddressBookQuery) ([]AddressObject, error)
	PutAddressObject(path string, card vcard.Card) (loc string, err error)
	DeleteAddressObject(path string) error

Backend is a CardDAV server backend.

type Client added in v0.2.0

type Client struct {
	// contains filtered or unexported fields

Client provides access to a remote CardDAV server.

func NewClient added in v0.2.0

func NewClient(c webdav.HTTPClient, endpoint string) (*Client, error)

func (*Client) FindAddressBookHomeSet added in v0.2.0

func (c *Client) FindAddressBookHomeSet(principal string) (string, error)

func (*Client) FindAddressBooks added in v0.2.0

func (c *Client) FindAddressBooks(addressBookHomeSet string) ([]AddressBook, error)

func (*Client) GetAddressObject added in v0.3.0

func (c *Client) GetAddressObject(path string) (*AddressObject, error)

func (*Client) HasSupport added in v0.3.0

func (c *Client) HasSupport() error

func (*Client) MultiGetAddressBook added in v0.2.0

func (c *Client) MultiGetAddressBook(path string, multiGet *AddressBookMultiGet) ([]AddressObject, error)

func (*Client) PutAddressObject added in v0.3.0

func (c *Client) PutAddressObject(path string, card vcard.Card) (*AddressObject, error)

func (*Client) QueryAddressBook added in v0.2.0

func (c *Client) QueryAddressBook(addressBook string, query *AddressBookQuery) ([]AddressObject, error)

func (*Client) SyncCollection added in v0.3.1

func (c *Client) SyncCollection(path string, query *SyncQuery) (*SyncResponse, error)

SyncCollection do a sync-collection operation on resource(path), it returns a SyncResponse

type FilterTest added in v0.2.0

type FilterTest string
const (
	FilterAnyOf FilterTest = "anyof"
	FilterAllOf FilterTest = "allof"

type Handler

type Handler struct {
	Backend Backend

Handler handles CardDAV HTTP requests. It can be used to create a CardDAV server.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

type MatchType added in v0.2.0

type MatchType string
const (
	MatchEquals     MatchType = "equals"
	MatchContains   MatchType = "contains"
	MatchStartsWith MatchType = "starts-with"
	MatchEndsWith   MatchType = "ends-with"

type ParamFilter added in v0.2.0

type ParamFilter struct {
	Name string

	// if IsNotDefined is set, TextMatch needs to be unset
	IsNotDefined bool
	TextMatch    *TextMatch

type PropFilter added in v0.2.0

type PropFilter struct {
	Name string
	Test FilterTest // defaults to FilterAnyOf

	// if IsNotDefined is set, TextMatches and Params need to be unset
	IsNotDefined bool
	TextMatches  []TextMatch
	Params       []ParamFilter

type SyncQuery added in v0.3.1

type SyncQuery struct {
	DataRequest AddressDataRequest
	SyncToken   string
	Limit       int // <= 0 means unlimited

SyncQuery is the query struct represents a sync-collection request

type SyncResponse added in v0.3.1

type SyncResponse struct {
	SyncToken string
	Updated   []AddressObject
	Deleted   []string

SyncResponse contains the returned sync-token for next time

type TextMatch added in v0.2.0

type TextMatch struct {
	Text            string
	NegateCondition bool
	MatchType       MatchType // defaults to MatchContains

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL