aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-12-21 01:06:12 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-12-21 01:06:12 +0100
commitf37c6e605107764cd1fd6d3fbd3d975ea8a3b8b8 (patch)
tree0d92fa89b45a97762833b35847d090b7e2bc24fb /client.go
parent81db1c84aa4916a02887ab436beb53f0b090bc1e (diff)
WIP
Diffstat (limited to 'client.go')
-rw-r--r--client.go26
1 files changed, 24 insertions, 2 deletions
diff --git a/client.go b/client.go
index 7a023b5..4737995 100644
--- a/client.go
+++ b/client.go
@@ -75,7 +75,7 @@ func (c *Client) post(s Signer, v interface{}) error {
if err != nil {
return err
}
- log.Println(string(body))
+ log.Println("POST", string(body))
signed, err := s.Sign(body, c)
if err != nil {
@@ -88,6 +88,8 @@ func (c *Client) post(s Signer, v interface{}) error {
}
defer resp.Body.Close()
c.parseHeader(resp)
+ log.Println("STATUS", resp.Status)
+ log.Println("HEADER", c)
if resp.StatusCode >= http.StatusBadRequest {
var p Problem
@@ -168,11 +170,16 @@ func (c *Client) Register(a *Account) (*Registration, error) {
// Agree to TOS
func (c *Client) Agree(a *Account) (*Registration, error) {
+ tos := c.Link["terms-of-service"]
+ if tos == "" {
+ return nil, errors.New("TOS agreed")
+ }
r := &Registration{
Resource: ResRegister,
Contact: a.Contact,
- Agreement: c.Link["terms-of-service"],
+ Agreement: tos,
}
+ log.Println("TOS", tos)
return r, c.post(a, r)
}
@@ -191,3 +198,18 @@ func (c *Client) Authorize(a *Account, domain string) (*Authorization, error) {
func (c Client) String() string {
return fmt.Sprintf("Location: %v Links: %v", c.Location, c.Link)
}
+
+////////////////////////////////////////////////////////////////////////
+
+// Register
+// 1. new-reg
+// arg: contact
+// StatusCreated (201) or StatusConflict (409)
+// Response: Location, Link
+// 2. reg
+// arg: contact, tos
+// StatusOk
+
+// Authorize
+
+// Certificate