mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 08:14:15 +00:00
carddav: define XML names as globals
This commit is contained in:
parent
bf666bb2fb
commit
402593c5c6
@ -1,8 +1,6 @@
|
||||
package carddav
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
|
||||
"github.com/emersion/go-vcard"
|
||||
)
|
||||
|
||||
|
@ -2,7 +2,6 @@ package carddav
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/xml"
|
||||
"net/http"
|
||||
|
||||
"github.com/emersion/go-vcard"
|
||||
@ -34,9 +33,7 @@ func (c *Client) SetBasicAuth(username, password string) {
|
||||
}
|
||||
|
||||
func (c *Client) FindAddressBookHomeSet(principal string) (string, error) {
|
||||
name := xml.Name{namespace, "addressbook-home-set"}
|
||||
propfind := internal.NewPropNamePropfind(name)
|
||||
|
||||
propfind := internal.NewPropNamePropfind(addressBookHomeSetName)
|
||||
resp, err := c.ic.PropfindFlat(principal, propfind)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -51,10 +48,7 @@ func (c *Client) FindAddressBookHomeSet(principal string) (string, error) {
|
||||
}
|
||||
|
||||
func (c *Client) FindAddressBooks(addressBookHomeSet string) ([]AddressBook, error) {
|
||||
resTypeName := xml.Name{"DAV:", "resourcetype"}
|
||||
descName := xml.Name{namespace, "addressbook-description"}
|
||||
propfind := internal.NewPropNamePropfind(resTypeName, descName)
|
||||
|
||||
propfind := internal.NewPropNamePropfind(internal.ResourceTypeName, addressBookDescriptionName)
|
||||
ms, err := c.ic.Propfind(addressBookHomeSet, internal.DepthOne, propfind)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -8,7 +8,11 @@ import (
|
||||
|
||||
const namespace = "urn:ietf:params:xml:ns:carddav"
|
||||
|
||||
var addressBookName = xml.Name{namespace, "addressbook"}
|
||||
var (
|
||||
addressBookName = xml.Name{namespace, "addressbook"}
|
||||
addressBookHomeSetName = xml.Name{namespace, "addressbook-home-set"}
|
||||
addressBookDescriptionName = xml.Name{namespace, "addressbook-description"}
|
||||
)
|
||||
|
||||
type addressbookHomeSet struct {
|
||||
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:carddav addressbook-home-set"`
|
||||
|
Loading…
Reference in New Issue
Block a user