Add comments to exported methods for api package

This commit is contained in:
Joel Speed 2018-12-20 09:37:02 +00:00
parent ee913fb788
commit a65ceb2c41
No known key found for this signature in database
GPG Key ID: 6E80578D6751DEFB

View File

@ -10,6 +10,7 @@ import (
"github.com/bitly/go-simplejson" "github.com/bitly/go-simplejson"
) )
// Request parses the request body into a simplejson.Json object
func Request(req *http.Request) (*simplejson.Json, error) { func Request(req *http.Request) (*simplejson.Json, error) {
resp, err := http.DefaultClient.Do(req) resp, err := http.DefaultClient.Do(req)
if err != nil { if err != nil {
@ -32,6 +33,7 @@ func Request(req *http.Request) (*simplejson.Json, error) {
return data, nil return data, nil
} }
// RequestJSON parses the request body into the given interface
func RequestJSON(req *http.Request, v interface{}) error { func RequestJSON(req *http.Request, v interface{}) error {
resp, err := http.DefaultClient.Do(req) resp, err := http.DefaultClient.Do(req)
if err != nil { if err != nil {
@ -50,6 +52,7 @@ func RequestJSON(req *http.Request, v interface{}) error {
return json.Unmarshal(body, v) return json.Unmarshal(body, v)
} }
// RequestUnparsedResponse performs a GET and returns the raw response object
func RequestUnparsedResponse(url string, header http.Header) (resp *http.Response, err error) { func RequestUnparsedResponse(url string, header http.Header) (resp *http.Response, err error) {
req, err := http.NewRequest("GET", url, nil) req, err := http.NewRequest("GET", url, nil)
if err != nil { if err != nil {