Skip to content

Adds support for context.Context#41

Merged
cyberdelia merged 1 commit intointeragent:masterfrom
alindeman:ctx
Mar 6, 2017
Merged

Adds support for context.Context#41
cyberdelia merged 1 commit intointeragent:masterfrom
alindeman:ctx

Conversation

@alindeman
Copy link
Copy Markdown
Contributor

The context package is the most official way to timeout or otherwise cancel requests in Go >= 1.7.

For some prior art from other open source clients, see go-github and go-asana.

Example of generated code:

// Get sends a GET request and decodes the response into v.
func (s *Service) Get(ctx context.Context, v interface{}, path string, query interface{}, lr *ListRange) error {
        return s.Do(ctx, v, "GET", path, nil, query, lr)
}


// Info for account.
func (s *Service) AccountInfo(ctx context.Context) (*AccountInfoResult, error) {
        var account AccountInfoResult
        return &account, s.Get(ctx, &account, fmt.Sprintf("/account"), nil, nil)
}

@cyberdelia
Copy link
Copy Markdown
Member

Looks fine 👍

@cyberdelia cyberdelia merged commit 2e69bce into interagent:master Mar 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants