9 "github.com/bitly/go-simplejson"
10 "github.com/pusher/oauth2_proxy/logger"
13// Request parses the request body into a simplejson.Json object
14func Request(req *http.Request) (*simplejson.Json, error) {
15 resp, err := http.DefaultClient.Do(req)
17 logger.Printf("%s %s %s", req.Method, req.URL, err)
20 body, err := ioutil.ReadAll(resp.Body)
22 logger.Printf("%d %s %s %s", resp.StatusCode, req.Method, req.URL, body)
26 if resp.StatusCode != 200 {
27 return nil, fmt.Errorf("got %d %s", resp.StatusCode, body)
29 data, err := simplejson.NewJson(body)
36// RequestJSON parses the request body into the given interface
37func RequestJSON(req *http.Request, v interface{}) error {
38 resp, err := http.DefaultClient.Do(req)
40 logger.Printf("%s %s %s", req.Method, req.URL, err)
43 body, err := ioutil.ReadAll(resp.Body)
45 logger.Printf("%d %s %s %s", resp.StatusCode, req.Method, req.URL, body)
49 if resp.StatusCode != 200 {
50 return fmt.Errorf("got %d %s", resp.StatusCode, body)
52 return json.Unmarshal(body, v)
55// RequestUnparsedResponse performs a GET and returns the raw response object
56func RequestUnparsedResponse(url string, header http.Header) (resp *http.Response, err error) {
57 req, err := http.NewRequest("GET", url, nil)
63 return http.DefaultClient.Do(req)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list