Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #6. add support for golang 1.8.3 #7

Merged
merged 1 commit into from
Aug 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

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