aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-12-12 22:10:09 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-12-12 22:10:09 +0100
commitb0aa5a6da8f5426e83c9fb8be0d7c344e40c3363 (patch)
tree71d9992229234870d0f0a44acd2dffabba4f53e7
parent0f28bef66af6696d2f7c7ccca3e9e9993af46ee5 (diff)
kiss
-rw-r--r--client.go24
-rw-r--r--cmd/x/main.go6
2 files changed, 10 insertions, 20 deletions
diff --git a/client.go b/client.go
index 8efa32c..e2d8492 100644
--- a/client.go
+++ b/client.go
@@ -146,22 +146,18 @@ func replyNonce(r *http.Response) string {
challenge cert-chain
*/
-func (c *Client) Register(a *Account) error {
+func (c *Client) Register(a *Account) (RegistrationResp, error) {
rq := Registration{
Resource: ResNewReg,
Contact: a.Contact,
}
re := RegistrationResp{}
err := c.request(c.Dir.NewReg, a, rq, &re)
- if err != nil {
- return err
- }
- log.Println(re)
- return err
+ return re, err
}
// Agree to TOS
-func (c *Client) Agree(a *Account) error {
+func (c *Client) Agree(a *Account) (RegistrationResp, error) {
rq := Registration{
Resource: ResRegister,
Contact: a.Contact,
@@ -169,14 +165,10 @@ func (c *Client) Agree(a *Account) error {
}
re := RegistrationResp{}
err := c.request(c.Location, a, rq, &re)
- if err != nil {
- return err
- }
- log.Println(re)
- return err
+ return re, err
}
-func (c *Client) Authorize(a *Account, domain string) error {
+func (c *Client) Authorize(a *Account, domain string) (AuthorizationResp, error) {
rq := Authorization{
Resource: ResNewAuthz,
Identifier: Identifier{
@@ -186,9 +178,5 @@ func (c *Client) Authorize(a *Account, domain string) error {
}
re := AuthorizationResp{}
err := c.request(c.Dir.NewAuthz, a, rq, &re)
- if err != nil {
- return err
- }
- log.Println(re)
- return err
+ return re, err
}
diff --git a/cmd/x/main.go b/cmd/x/main.go
index 0e6cf71..72ad0e4 100644
--- a/cmd/x/main.go
+++ b/cmd/x/main.go
@@ -38,15 +38,17 @@ func main() {
}
*/
- err = c.Register(a)
+ re, err := c.Register(a)
if err != nil {
log.Fatal(err)
}
log.Printf("%+v\n", c)
+ log.Printf("%+v\n", re)
- err = c.Agree(a)
+ re, err = c.Agree(a)
if err != nil {
log.Fatal(err)
}
log.Printf("%+v\n", c)
+ log.Printf("%+v\n", re)
}