aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-12-10 17:01:14 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-12-10 17:01:14 +0100
commit54975553c4b67d2b2d9d6edcbf18dbcbdc508fec (patch)
tree368e07db912904c7982358ad60e76a35404121b5 /client.go
parentf8176a30d5193f77fd7a76492f8245620035ffb7 (diff)
Reimplement registration
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
+}