Comments (8)
@alexmontecucco Sorry for delayed response. Just got occupied with my aah framework work, getting ready to make an initial public release, etc.
When I designed the resty
, I have followed convention of golang
Setter
. You can see that with every method exposed from resty
for setting values.
I understand your question, I hope and believe it won't hurt to change these two SetFormData
, SetQueryParam
methods. Because resty
already provides dedicated methods for setting multiple values SetMultiValueQueryParams
and SetMultiValueFormData
.
Now coming to your problem, as you have mentioned-
prevents from overriding existing keys.
Can you please explain me your use case where you unable to do so? The reason is if you're facing an issue other resty
users could face. I would like to solve that.
Looking forward to your response.
from resty.
@jeevatkm Thx for you reply.
My concern is (from request.go
):
// SetQueryParam method sets single paramater and its value in the current request.
// It will be formed as query string for the request.
// Example: `search=kitchen%20papers&size=large` in the URL after `?` mark.
// resty.R().
// SetQueryParam("search", "kitchen papers").
// SetQueryParam("size", "large")
// Also you can override query params value, which was set at client instance level
//
func (r *Request) SetQueryParam(param, value string) *Request {
r.QueryParam.Add(param, value)
return r
}
Both method name and doc are misleading because SetQueryParam
is not setting but adding (r.QueryParam.Add(param, value)
).
url.Values
type has four functions: Get
, Set
, Add
and Del
.
It is still possible to achieve the desired result by not using the SetQueryParam
function and directly use the QueryParam
attribute of the Request
object though.
from resty.
Thanks @alexmontecucco. Okay let's make the misleading clear.
I will do this in coming v0.12
release, I'm capturing it here so users can refer it -
SetQueryParam
andSetFormData
will be updated to use methodSet
internally
resty
user have to use existing methods SetMultiValueQueryParams
, SetMultiValueFormData
for multi values which uses method Add
internally.
I hope this doesn't affect users.
PS: If you're interested you can send PR for this update.
from resty.
I don't understand why SetMultiValueQueryParams
and SetMultiValueFormData
still need to use the Add
internally. Is it to avoid breaking compatibility.
For SetQueryParam
and SetFormData
your suggestion is to simply change the Add
to Set
right ?
from resty.
No, it's not about breaking compatibility.
Yes, changing it from Add
to Set
for SetQueryParam
and SetFormData
.
The way Set
works from url.Values
is; it replaces the existing values. We will not able to add multi values. So Add
is required for multi values.
Multi value method added on #28.
from resty.
Ok got it, I forgot, thx.
Will push something this week / weekend.
from resty.
Thanks @alexmontecucco.
from resty.
Closed by #71
from resty.
Related Issues (20)
- Call to http.DetectContentType has trailing NUL bytes in buffer HOT 1
- The SetContentLength(boo) method may cause an out-of-memory issue when uploading large files, such as 5GB. HOT 1
- CVE-2023-45286 HOT 3
- Breaks application from Ctrl-C handling HOT 1
- Brotli support HOT 1
- How to handle response if a call to API returns 200 with struct A, or 201 with struct B? HOT 3
- SetResult failed with httpmock HOT 2
- CVE-2023-45286: HTTP request body disclosure HOT 3
- SetProxy HOT 3
- The request with SetFileReader retry time great than 1 will has issues HOT 1
- Signing requests with path parameters HOT 1
- Clone or copy of existing client HOT 6
- cache middleware HOT 4
- retrying of non-idempotent methods HOT 2
- Path param encoding is broken
- can't use image.decode on rawbody HOT 1
- Can it support socket5 proxy? HOT 2
- Resty retry function does not work in Slack as custom http client HOT 1
- Middleware around resty.Request.Execute including retries HOT 1
- about proxy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from resty.