aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-11-27 01:03:39 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-11-27 01:03:39 +0100
commit2858c99c261761678ad16e35dacc9cdcd25dca44 (patch)
tree51e0a0442b4488a86361df3314cfba594b90ef4f /client.go
parentb084114266ed0251abf3946f22ba64851e9b2c96 (diff)
Add registration stub
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
+}