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

chore: follow up context.Context support #103

Merged
merged 1 commit into from
May 3, 2021
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
20 changes: 3 additions & 17 deletions rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package rest

import (
"bytes"
"context"
"io/ioutil"
"net/http"
"net/url"

"golang.org/x/net/context"
)

// Version represents the current version of the rest library
Expand Down Expand Up @@ -115,7 +114,7 @@ func API(request Request) (*Response, error) {

// Send uses the DefaultClient to send your request
func Send(request Request) (*Response, error) {
return DefaultClient.Send(request)
return SendWithContext(context.Background(), request)
}

// SendWithContext uses the DefaultClient to send your request with the provided context.
Expand All @@ -138,20 +137,7 @@ func (c *Client) API(request Request) (*Response, error) {

// Send will build your request, make the request, and build your response.
func (c *Client) Send(request Request) (*Response, error) {
// Build the HTTP request object.
req, err := BuildRequestObject(request)
if err != nil {
return nil, err
}

// Build the HTTP client and make the request.
res, err := c.MakeRequest(req)
if err != nil {
return nil, err
}

// Build Response object.
return BuildResponse(res)
return c.SendWithContext(context.Background(), request)
}

// SendWithContext will build your request passing in the provided context, make the request, and build your response.
Expand Down