aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-12-05 17:59:31 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-12-05 17:59:31 +0100
commit016a0a8c3ec0666cf46d39abed1bcac0936aa846 (patch)
treebf7ff3d89a997f8019def95e7cdff44970c96d86
parentd94906b4fd64aed44c1e3e438de9dae196bd34c4 (diff)
Put message structures and types together
-rw-r--r--client.go28
-rw-r--r--messages.go28
2 files changed, 28 insertions, 28 deletions
diff --git a/client.go b/client.go
index ae3d81e..bf55f17 100644
--- a/client.go
+++ b/client.go
@@ -3,40 +3,12 @@ package acme
import (
"bytes"
"encoding/json"
- "fmt"
"log"
"net/http"
"net/textproto"
"regexp"
)
-type Status int
-
-const (
- StatusUnknown Status = iota
- StatusPending
- StatusProcessing
- StatusValid
- StatusInvalid
- StatusRevoked
-)
-
-func (s *Status) UnmarshalJSON(b []byte) error {
- var status = map[string]Status{
- "unknown": StatusUnknown,
- "pending": StatusPending,
- "processing": StatusProcessing,
- "valid": StatusValid,
- "invalid": StatusInvalid,
- "revoked": StatusRevoked,
- }
- if st, ok := status[string(b)]; ok {
- *s = st
- return nil
- }
- return fmt.Errorf("unknown status %v", string(b))
-}
-
type NonceSigner interface {
Sign([]byte) ([]byte, error)
parseNonce(*http.Response)
diff --git a/messages.go b/messages.go
index b5a1738..28d531b 100644
--- a/messages.go
+++ b/messages.go
@@ -1,6 +1,7 @@
package acme
import (
+ "fmt"
"net"
"time"
)
@@ -81,3 +82,30 @@ type Problem struct {
Detail string `json:"detail"`
Instance string `json:"instance"`
}
+
+type Status int
+
+const (
+ StatusUnknown Status = iota
+ StatusPending
+ StatusProcessing
+ StatusValid
+ StatusInvalid
+ StatusRevoked
+)
+
+func (s *Status) UnmarshalJSON(b []byte) error {
+ var status = map[string]Status{
+ "unknown": StatusUnknown,
+ "pending": StatusPending,
+ "processing": StatusProcessing,
+ "valid": StatusValid,
+ "invalid": StatusInvalid,
+ "revoked": StatusRevoked,
+ }
+ if st, ok := status[string(b)]; ok {
+ *s = st
+ return nil
+ }
+ return fmt.Errorf("unknown status %v", string(b))
+}