aboutsummaryrefslogtreecommitdiff
path: root/client.go
blob: 8759ad1fe4921f225257b7dc887f5c93bb983dfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package acme

import (
	"bytes"
	"encoding/json"
	"io/ioutil"
	"log"
	"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
	}
	log.Println(string(body))
	return nil
	// premature debug abort

	_, err = http.Post(uri, "application/jose+json", bytes.NewReader(body))
	if err != nil {
		return err
	}
	return nil
}