aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'client.go')
-rw-r--r--client.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/client.go b/client.go
new file mode 100644
index 0000000..f92d15d
--- /dev/null
+++ b/client.go
@@ -0,0 +1,32 @@
+package acme
+
+import (
+ "encoding/json"
+ "io/ioutil"
+ "net/http"
+)
+
+func Get(uri string, v interface{}) error {
+ resp, err := http.Get(uri)
+ if err != nil {
+ return err
+ }
+ defer resp.Body.Close()
+ body, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ return err
+ }
+ return json.Unmarshal(body, v)
+}
+
+func Post(uri string, v interface{}) error {
+ body, err := json.Marshal(v)
+ if err != nil {
+ return err
+ }
+ _, err := http.Post(uri, "application/jose+json", body)
+ if err != nil {
+ return err
+ }
+ return nil
+}