Skip to content

Commit

Permalink
fixes #6. add support for golang 1.8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Korolyov committed Aug 28, 2017
1 parent 8363a55 commit e661eba
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"bytes"
"context"
"encoding/json"
"io"
"io/ioutil"
"net/http"

Expand Down Expand Up @@ -104,17 +105,17 @@ func OptEnv(env env) Option {
// Call does HTTP request with given params using set HTTP client. Response will be decoded into respObj.
// Error may be returned if something went wrong. If API return error as response, then Call returns error of type zooz.Error.
func (c *Client) Call(ctx context.Context, method, path string, headers map[string]string, reqObj interface{}, respObj interface{}) (callErr error) {
var reqBody []byte
var err error
var reqBody io.Reader

This comment has been minimized.

Copy link
@mkabischev

mkabischev Aug 28, 2017

Contributor

You can also use https://golang.org/pkg/net/http/#NoBody for that.

reqBody := http.NoBody

...

I think it's a little bit more explicit. It doesn't change the behavior, so it's up to you.


if reqObj != nil {
reqBody, err = json.Marshal(reqObj)
reqBodyBytes, err := json.Marshal(reqObj)
if err != nil {
return errors.Wrap(err, "failed to marshal request body")
}
reqBody = bytes.NewBuffer(reqBodyBytes)
}

req, err := http.NewRequest(method, apiURL+path, bytes.NewBuffer(reqBody))
req, err := http.NewRequest(method, apiURL+path, reqBody)
if err != nil {
return errors.Wrap(err, "failed to create HTTP request")
}
Expand Down

0 comments on commit e661eba

Please sign in to comment.