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)
- why lock udBeforeRequestLock and udBeforeRequestLock in execute HOT 3
- Why TLS Timeout error can't be handle by Retries ? HOT 2
- Can I send a custom HTTP verb?
- Using it within a goroutine can cause inaccurate delay measurements returned by the Time function. HOT 2
- compilation fails with bazel in resty 2.8 HOT 4
- .SetTimeout() option breaks functionality, results in showing the duration of HTTP request wrong. HOT 5
- Add clone method in `Request`
- Unable to test Body() due to unexported variable body HOT 3
- Setting context for all request? HOT 6
- Problem with a client requesting a TCP service HOT 4
- [BUG] DigestAuth with SetBody will be 'http: ContentLength=54 with Body length 0' HOT 3
- SetResult replaces nested struct with a map inside a map HOT 1
- Resty client global variable HOT 1
- parseResponseBody > Unmarshalc cannot unmarshal string into Go value of type map[string]interface {}
- DATA RACE in resty's middleware (go-resty/resty/v2.releaseBuffer()) HOT 2
- What's the idiomatic way of changing proxies for the client? HOT 1
- Add support for go-logr/logr on resty HOT 1
- Is the `SetTimeout()` respected by the default context?
- Request body is written multiple times HOT 2
- Result value has been set and parsed correctly and the request returns successfully, the correct address cannot be recognized HOT 2
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.