aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'client.go')
-rw-r--r--client.go20
1 files changed, 8 insertions, 12 deletions
diff --git a/client.go b/client.go
index b144e6f..238543c 100644
--- a/client.go
+++ b/client.go
@@ -4,26 +4,25 @@ import (
"bytes"
"encoding/json"
"errors"
- "log"
"net/http"
"net/textproto"
"regexp"
"time"
-
- "github.com/square/go-jose"
)
+// Solver decribes a solving interface
type Solver interface {
Solve()
}
-type Signer interface {
- Sign([]byte, jose.NonceSource) ([]byte, error)
-}
+// Links to the next stage
+type Links map[string]string
+// Client ...
type Client struct {
Dir Directory
nonce chan string
+ Links Links
}
// NewClient fetches directory and initializes nonce
@@ -71,7 +70,7 @@ func (c Client) Nonce() (string, error) {
// Post is used for
// new-reg, new-authz, challenge, new-cert
-func (c Client) Post(s Signer, uri string, v interface{}) (*http.Response, error) {
+func (c *Client) Post(s Signer, uri string, v interface{}) (*http.Response, error) {
body, err := json.Marshal(v)
if err != nil {
return nil, err
@@ -89,19 +88,16 @@ func (c Client) Post(s Signer, uri string, v interface{}) (*http.Response, error
}
c.nonce <- replyNonce(resp)
+ c.Links = links(resp)
if resp.StatusCode >= http.StatusBadRequest {
return nil, handleError(resp)
}
- log.Printf("%+v\n", link(resp))
-
return resp, nil
}
-type Links map[string]string
-
-func link(r *http.Response) Links {
+func links(r *http.Response) Links {
links := make(Links)
key := textproto.CanonicalMIMEHeaderKey("Link")
reg := regexp.MustCompile(`^<(.*)>;rel="(.*)"`)