go-resty / resty

Simple HTTP and REST client library for Go
MIT License
9.89k stars 696 forks source link

fix: correct url path params processing order #519 #705

Closed jeevatkm closed 11 months ago

jeevatkm commented 11 months ago

Closes #519

codecov[bot] commented 11 months ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (4801bed) 95.65% compared to head (28012cc) 95.65%. Report is 1 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #705 +/- ## ======================================= Coverage 95.65% 95.65% ======================================= Files 12 12 Lines 1611 1611 ======================================= Hits 1541 1541 Misses 42 42 Partials 28 28 ``` | [Files Changed](https://app.codecov.io/gh/go-resty/resty/pull/705?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-resty) | Coverage Δ | | |---|---|---| | [middleware.go](https://app.codecov.io/gh/go-resty/resty/pull/705?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-resty#diff-bWlkZGxld2FyZS5nbw==) | `92.22% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

SVilgelm commented 11 months ago

@jeevatkm, the previous implementation was correct. Let's say we have url example.com/{foo}/{bar}/ And have the parameters:

Client: {"foo": "123"}
Request: {"foo": "456", "bar": "789"}

r.URL = "example.com/{foo}/{bar}/"

the current code will apply the parameters from Client first:

so the request parameters must be applied first, then the client, or we need to change the logic to use a map and strings.Replacer

jeevatkm commented 11 months ago

@SVilgelm Thanks for reminding me. Damn it, last night, how did I forget this!! 🤦 I will revert the changes.

SVilgelm commented 11 months ago

We need to add the unit tests to prevent such thing in the future, I can do it later today