-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Patches Dataset and JSON handler: #43
Conversation
- Dataset#uri incorrectly omits params from non-GET requests. - JSONRequest clobbers URI path (see https://discourse.rom-rb.org/t/rom-http-gateway-and-dataset-uri-paths/407) - JSONRequest redundantly sets URI query
IMO |
uri.query = param_encoder.call(params) | ||
URI(join_path(super, path)).tap do |uri| | ||
if params.any? | ||
uri.query = param_encoder.call(params) |
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.
If I'm not mistaken, this will add all params as query params, even in a POST request, which could be bad if posting a blob of text for example, and is probably not desired in most scenarios. Perhaps it would be better to add a query_params
option to Dataset
?
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.
@AMHOL Oh, right. :) It so happens that the app I am cutting my rom-rb teeth on uses the request body to POST JSON data. I can amend this as you suggest.
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.
@AMHOL On further thought (what a day!) the use of both query_params
and params
seems ... confusing. I wonder if it would be too complicated to just POST params in the body if there is no other request data? E.g., in my app I have a request_data
string var https://github.com/dchandekstark/solrbee/blob/main/lib/rom/solr/dataset.rb#L12
which gets dumped into the request body. I could see dumping the params into the body if request_data is nil or empty.
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.
Yeah it could be confusing, I'm not sure of a better way to go about it myself, I like the idea of just having params sent as the request body though and having a separate query_params
option does solve that, perhaps we could have a query_params
option as well as a body_params
option, probably best to wait for @solnic to weigh in on this though.
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 like the idea of query_params
and body_params
, it would make things much more obvious.
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.
@dchandekstark the idea with an override-able base path is to allow for querying from a relation when that resource is nested under another resource, i.e. being able to query |
@AMHOL I get overriding |
@dchandekstark it doesn't in https://github.com/PetRescue/pr-pin/blob/master/lib/pr/pin/adapter/handlers/json_request.rb as that's just using the |
OK, thanks @AMHOL. |
I think this PR is now superseded by #44. |
Closing in deference to #44. |
https://discourse.rom-rb.org/t/rom-http-gateway-and-dataset-uri-paths/407)
by hard-coding URI.www_encode_form)