feat: Set default User-Agent and fix request option merging #625
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.
π§ Changes
This PR fixes multiple issues related to HTTP headers and request options in the SDK:
User-Agent Header
internal.UserAgentTransport()to set User-Agent header via transport wrapperGo-Auth0/v2.0.0instead ofGo-http-client/1.1Auth0-Client Header
internal.Auth0ClientInfoTransport()for Auth0-Client headerWithHTTPHeaderensures the header cannot be accidentally overwritten by user optionsRequest Options - Merging Behavior
HTTPHeaderOptionnow merges headers instead of replacing the entire header mapBodyPropertiesOptionnow merges properties instead of replacingQueryParametersOptionnow merges query parameters instead of replacingDebug Logging
DebugTransportnow dumps request after inner transports modify itCode Cleanup
encoding/base64,encoding/json) from management.goπ References
This addresses issues where:
WithHTTPHeader/WithBodyProperties/WithQueryParameterscalls would overwrite instead of merge㪠Testing
Existing Tests: All existing tests pass
go test ./internal/client/... -run TestDebug- β Passgo test ./management/client/...- β Passmake lint- β PassManual Testing:
Created test client with debug logging enabled and verified:
Go-Auth0/v2.0.0in debug outputTest Scenario:
Before: Debug log showed
User-Agent: Go-http-client/1.1After: Debug log shows
User-Agent: Go-Auth0/v2.0.0π Checklist