Do not use http.DefaultClient and more use of WithTransport#27
Merged
myleshorton merged 4 commits intomainfrom Dec 19, 2025
Merged
Do not use http.DefaultClient and more use of WithTransport#27myleshorton merged 4 commits intomainfrom
myleshorton merged 4 commits intomainfrom
Conversation
Contributor
Author
|
Gonna pull this in. There is still definitely a race condition if |
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request refactors the transport management system in the Kindling library to make it more extensible and user-friendly. It removes the use of http.DefaultClient, introduces a minimal Transport interface, and simplifies how custom transports are added.
Key Changes:
- Introduced a
Transportinterface with three methods (NewRoundTripper,MaxLength,Name) for custom transport implementations - Removed cached
httpClientfield from thekindlingstruct;NewHTTPClient()now always returns a new client - Refactored transport options (
WithDomainFronting,WithDNSTunnel,WithAMPCache,WithProxyless) to use the newWithTransportfunction and addedemptyOptionfor better error handling
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| kindling.go | Removed cached httpClient, introduced Transport interface, added WithTransport function, refactored transport options to use WithTransport, and added emptyOption type for handling nil dependencies |
| README.md | Added documentation for the new Transport interface with detailed method descriptions and usage example |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors how transports are added and managed in the Kindling library, making the transport system more extensible and easier to use. It introduces a minimal
Transportinterface, simplifies the addition of new transports, and cleans up related code and documentation. The most important changes are grouped below.Transport System Refactoring
Transportinterface, defining the required methods for custom transports, and updated the code and documentation to use this interface. (kindling.go,README.md) [1] [2]WithTransportoption to allow users to add any custom transport that implements theTransportinterface. (kindling.go)WithDomainFronting,WithDNSTunnel,WithAMPCache,WithProxyless) to leverage the newWithTransportmechanism and improve error handling. (kindling.go) [1] [2]Code Simplification and Cleanup
httpClientfield from thekindlingstruct and updatedNewHTTPClientto always return a newhttp.Clientwith the appropriate transport, simplifying thread safety and usage. (kindling.go) [1] [2]emptyOptiontype to handle cases where an option is skipped due to missing dependencies, improving robustness. (kindling.go)