Skip to content

Conversation

lightster
Copy link

@lightster lightster commented Sep 22, 2025

Fixes

This PR adds support for passing a Go Context when making an API request. All API methods will now have a matching function for passing a Go Context when make the API request. For example, the Taskrouter Workspaces CreateTask function will now have a corresponding CreateTaskWithContext method that accepts a Go context.Context as its first parameter.

Closes #255. Supersedes #287. Supersedes #290.

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

} else {
defaultClient.SetAccountSid(username)
}
requestHandler = client.NewRequestHandler(defaultClient)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@manisha1997 Do you know if this twilio.go file is actually generated by twilio-oai-generator as documented in the file header? If so, could you provide guidance on where in twilio-oai-generator the twilio.go file is generated and how I can run the generation?

I have not been able to figure this out on my own as of yet.

Comment on lines +20 to +22
// If the base client supports context, add it to the request handler.
// Otherwise we leave it nil and the base client will be used.
clientWithContext, _ := client.(BaseClientWithContext)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Admittedly this is less than ideal, but it allows us to add Context support without breaking backwards compatibility.

@lightster lightster force-pushed the add-support-for-go-contexts branch from ba65a82 to d7e8c7d Compare September 22, 2025 05:46
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.

Please reintroduce context.Context
1 participant