all: add basic docs

This commit is contained in:
Simon Ser 2020-01-21 21:01:18 +01:00
parent f6d0a37ea4
commit 0469c3d389
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
6 changed files with 17 additions and 0 deletions

View File

@ -1,3 +1,6 @@
// Package carddav provides a client and server CardDAV implementation.
//
// CardDAV is defined in RFC 6352.
package carddav
import (

View File

@ -45,6 +45,7 @@ func Discover(domain string) (string, error) {
return u.String(), nil
}
// Client provides access to a remote CardDAV server.
type Client struct {
*webdav.Client

View File

@ -11,6 +11,7 @@ import (
// TODO: add support for multiple address books
// Backend is a CardDAV server backend.
type Backend interface {
AddressBook() (*AddressBook, error)
GetAddressObject(href string) (*AddressObject, error)
@ -18,10 +19,13 @@ type Backend interface {
QueryAddressObjects(query *AddressBookQuery) ([]AddressObject, error)
}
// Handler handles CardDAV HTTP requests. It can be used to create a CardDAV
// server.
type Handler struct {
Backend Backend
}
// ServeHTTP implements http.Handler.
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if h.Backend == nil {
http.Error(w, "carddav: no backend available", http.StatusInternalServerError)

View File

@ -11,6 +11,7 @@ import (
"github.com/emersion/go-webdav/internal"
)
// Client provides access to a remote WebDAV filesystem.
type Client struct {
ic *internal.Client
}

View File

@ -17,16 +17,20 @@ type File interface {
io.Seeker
}
// FileSystem is a WebDAV server backend.
type FileSystem interface {
Open(name string) (File, error)
Stat(name string) (os.FileInfo, error)
Readdir(name string) ([]os.FileInfo, error)
}
// Handler handles WebDAV HTTP requests. It can be used to create a WebDAV
// server.
type Handler struct {
FileSystem FileSystem
}
// ServeHTTP implements http.Handler.
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if h.FileSystem == nil {
http.Error(w, "webdav: no filesystem available", http.StatusInternalServerError)

4
webdav.go Normal file
View File

@ -0,0 +1,4 @@
// Package webdav provides a client and server WebDAV filesystem implementation.
//
// WebDAV is defined in RFC 4918.
package webdav