From 54975553c4b67d2b2d9d6edcbf18dbcbdc508fec Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Thu, 10 Dec 2015 17:01:14 +0100 Subject: Reimplement registration --- client.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'client.go') 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 +} -- cgit v1.2.3