mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 16:24:14 +00:00
all: add basic docs
This commit is contained in:
parent
f6d0a37ea4
commit
0469c3d389
@ -1,3 +1,6 @@
|
|||||||
|
// Package carddav provides a client and server CardDAV implementation.
|
||||||
|
//
|
||||||
|
// CardDAV is defined in RFC 6352.
|
||||||
package carddav
|
package carddav
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -45,6 +45,7 @@ func Discover(domain string) (string, error) {
|
|||||||
return u.String(), nil
|
return u.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Client provides access to a remote CardDAV server.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
*webdav.Client
|
*webdav.Client
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
// TODO: add support for multiple address books
|
// TODO: add support for multiple address books
|
||||||
|
|
||||||
|
// Backend is a CardDAV server backend.
|
||||||
type Backend interface {
|
type Backend interface {
|
||||||
AddressBook() (*AddressBook, error)
|
AddressBook() (*AddressBook, error)
|
||||||
GetAddressObject(href string) (*AddressObject, error)
|
GetAddressObject(href string) (*AddressObject, error)
|
||||||
@ -18,10 +19,13 @@ type Backend interface {
|
|||||||
QueryAddressObjects(query *AddressBookQuery) ([]AddressObject, error)
|
QueryAddressObjects(query *AddressBookQuery) ([]AddressObject, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handler handles CardDAV HTTP requests. It can be used to create a CardDAV
|
||||||
|
// server.
|
||||||
type Handler struct {
|
type Handler struct {
|
||||||
Backend Backend
|
Backend Backend
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ServeHTTP implements http.Handler.
|
||||||
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
if h.Backend == nil {
|
if h.Backend == nil {
|
||||||
http.Error(w, "carddav: no backend available", http.StatusInternalServerError)
|
http.Error(w, "carddav: no backend available", http.StatusInternalServerError)
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/emersion/go-webdav/internal"
|
"github.com/emersion/go-webdav/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Client provides access to a remote WebDAV filesystem.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
ic *internal.Client
|
ic *internal.Client
|
||||||
}
|
}
|
||||||
|
@ -17,16 +17,20 @@ type File interface {
|
|||||||
io.Seeker
|
io.Seeker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FileSystem is a WebDAV server backend.
|
||||||
type FileSystem interface {
|
type FileSystem interface {
|
||||||
Open(name string) (File, error)
|
Open(name string) (File, error)
|
||||||
Stat(name string) (os.FileInfo, error)
|
Stat(name string) (os.FileInfo, error)
|
||||||
Readdir(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 {
|
type Handler struct {
|
||||||
FileSystem FileSystem
|
FileSystem FileSystem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ServeHTTP implements http.Handler.
|
||||||
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
if h.FileSystem == nil {
|
if h.FileSystem == nil {
|
||||||
http.Error(w, "webdav: no filesystem available", http.StatusInternalServerError)
|
http.Error(w, "webdav: no filesystem available", http.StatusInternalServerError)
|
||||||
|
Loading…
Reference in New Issue
Block a user