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

fix: Params interface #210

Merged
merged 1 commit into from
Feb 2, 2024
Merged

fix: Params interface #210

merged 1 commit into from
Feb 2, 2024

Conversation

gkats
Copy link
Member

@gkats gkats commented Feb 1, 2024

Type of change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • 🌟 New feature (non-breaking change which adds functionality)
  • 🔨 Breaking change (fix or feature that would cause existing functionality)
  • 📖 Docs change / refactoring / dependency upgrade to change)

Description

Changed the Queryable interface to Params. Instead of operating on a url.Values object, implementing types should return a url.Values object. When we set the params to the querystring, we'll use the new interface method.

Added a custom implementation to join URL paths. The new implementation will preserve any query parameters in the URL. We can now replace url.JoinPath, which required us to use Go v1.19 and upwards.

Related Issue (optional)

@gkats gkats requested a review from a team as a code owner February 1, 2024 14:34
Changed the Queryable interface to Params. Instead of operating on a
url.Values object, implementing types should return a url.Values object.
When we set the params to the querystring, we'll use the new interface
method.
Added a custom implementation to join URL paths. The new implementation
will preserve any query parameters in the URL. We can now replace
url.JoinPath, which required us to use Go v1.19 and upwards.
@gkats gkats force-pushed the core-1511-params-querystring branch from 4341a6b to 9d5919e Compare February 1, 2024 14:42
paramsQuery := params.ToQuery()
for k, values := range paramsQuery {
for _, v := range values {
q.Set(k, v)
Copy link
Contributor

Choose a reason for hiding this comment

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

Set or Add? As long as we don't consider a possible future case where we must set a query parameter at the SDK level (I don't think there's one), should be 100% fine though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't sure as well, just thought that Set is stricter but yields clearer results. Values will be overriden.

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