From 2858c99c261761678ad16e35dacc9cdcd25dca44 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Fri, 27 Nov 2015 01:03:39 +0100 Subject: Add registration stub --- client.go | 32 ++++++++++++++++++++++++++++++++ http.go | 32 -------------------------------- registration.go | 6 ++++++ 3 files changed, 38 insertions(+), 32 deletions(-) create mode 100644 client.go delete mode 100644 http.go create mode 100644 registration.go 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 +} diff --git a/http.go b/http.go deleted file mode 100644 index f92d15d..0000000 --- a/http.go +++ /dev/null @@ -1,32 +0,0 @@ -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 -} diff --git a/registration.go b/registration.go new file mode 100644 index 0000000..ee77077 --- /dev/null +++ b/registration.go @@ -0,0 +1,6 @@ +package acme + +type NewRegistration struct { + Resource string `json:"resource"` + Contact []string `json:"contact"` +} -- cgit v1.2.3