aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'client.go')
-rw-r--r--client.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/client.go b/client.go
index e4b208c..6fcdbe0 100644
--- a/client.go
+++ b/client.go
@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"errors"
+ "io/ioutil"
"log"
"net/http"
"net/textproto"
@@ -130,3 +131,21 @@ func retryAfter(r *http.Response) time.Duration {
func replyNonce(r *http.Response) string {
return r.Header.Get("Replay-Nonce")
}
+
+func (c *Client) Register(a *Account) error {
+ r := Registration{
+ Resource: ResNewReg,
+ Contact: a.Contact,
+ }
+ resp, err := c.Post(a, c.Dir.NewReg, r)
+ if err != nil {
+ return err
+ }
+ defer resp.Body.Close()
+ body, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ return err
+ }
+ log.Println(string(body))
+ return nil
+}