-
Notifications
You must be signed in to change notification settings - Fork 17
Choose GET route by default in case of double route #465
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
Conversation
I've tested it by running Kuzzle with this branch kuzzleio/kuzzle#1519 |
Codecov Report
@@ Coverage Diff @@
## 7-dev #465 +/- ##
==========================================
+ Coverage 95.56% 95.57% +0.01%
==========================================
Files 32 32
Lines 1307 1312 +5
==========================================
+ Hits 1249 1254 +5
Misses 58 58
Continue to review full report at Codecov.
|
…ript into handle-double-routes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a few documentation problems to fix and this PR will be gtg
The route exists in `GET` and `POST`. | ||
By default, the SDK hits the `GET` one. | ||
You can force it to be `POST` in the `options`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be part of the route description, but should instead be a dedicated sub-chapter for the verb
option below.
Something such as:
#### verb
When instantiated with a HTTP protocol object, the SDK uses the GET API by default for this API route.
You can set the `verb` option to `POST` to force the SDK to use the POST API instead.
options.verb = 'POST'; | ||
for (const opt of ['from', 'size', 'scroll']) { | ||
request[opt] = options[opt]; | ||
delete options[opt]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's not directly related to this PR but here the options
object should not be mutated because the user may want to re-use it across subsequent calls
Co-Authored-By: Sébastien Cottinet <scottinet@protonmail.com>
Co-Authored-By: Sébastien Cottinet <scottinet@protonmail.com>
@Aschen despite our discussions, everything is OK |
What does this PR do ? This PR removes unintended changes on functional tests that will make them fail when kuzzleio/sdk-javascript#465 will be merged How should this be manually tested? Launch test with the actual released SDK Launch them with this version of the SDK kuzzleio/sdk-javascript#465
What does this PR do?
This PR changes the way we get the correct route if there is several of them.
Before this PR:
The SDK checked the size of the url, and chose the shortest.
If they had the same size, it chose the POST route.
And you could not force the verb in your request.
Now:
Same thing, except it chooses the GET route.
Plus, you can force the verb with the option
{verb: 'POST'}
How should this be manually tested?
Install this version of the sdk
npm install git://github.com/kuzzleio/sdk-javascript#handle-double-routes
Run Kuzzle in debug mod.
Run this script
You will see in the logs that the route verb was GET
Now uncomment the line
// ,{verb: 'POST'}
The route will be in POST.
You can do the same with
mGetUsers
Other changes
Adapt doc snippet test for
getAllStats
andgetLastStats
, because of the new properties order of the response object recently definedBoyscout