[WIP] QUARKS-96: postJson in HttpStreams #106
Conversation
@@ -46,6 +47,12 @@ Licensed to the Apache Software Foundation (ASF) under one | |||
t -> HttpGet.METHOD_NAME, uri, HttpResponders.json()); | |||
} | |||
|
|||
public static TStream<JsonObject> postJson(TStream<JsonObject> stream, |
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.
please add sufficient javadoc. extra credit: see https://issues.apache.org/jira/browse/QUARKS-97 :-)
Hi @dlaboss, I have added functionality to support postJson() method. I added a method to add body to HTTP requests. Could you please review the code? I will fix review comments and failing build together. |
* request1.addProperty("a", "abc"); | ||
* request1.addProperty("b", "42"); | ||
* TStream<JsonObject> rc = HttpStreams.getJson( | ||
* topology.collection(Arrays.asList(request1)), |
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.
nit: move the construction of the input stream outside of the getJson() invocation? It's not something that will ever occur in practice. Ditto the postJson() example below.
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.
Could you please elaborate on this one? I am not clear on this.
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.
e.g.,
TStream<JsonObject> requests = topology.collection(Arrays.asList(request1));
TStream<JsonObject> rc = HttpStreams.getJson(requests, ...)
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.
Oh okay.. i was thinking something complex and weird.
t -> HttpGet.METHOD_NAME, uri, HttpResponders.json()); | ||
} | ||
|
||
public static TStream<JsonObject> deleteJson(TStream<JsonObject> stream, |
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.
javadoc for {delete,put}Json()?
* | ||
* TStream<JsonObject> stream = topology.collection(Arrays.asList(body)); | ||
* TStream<JsonObject> rc = HttpStreams.postJson(stream, | ||
* HttpClients::noAuthentication, t -> url, t -> body); |
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 don't think you really want/mean t -> body
. Presumably the sample is trying to demonstrate posting each tuple from a stream as the body of a POST to the specified url. To do that you need to specify 't -> t' (or Functions.identity()
), right?
Also the description of @param body
needs work. The function isn't returning an HttpEntity anymore. It's a function that for each JsonObject tuple from stream, returns a JsonObject whose JSON will be the body of the POST request. Right?
sorry for the delay... |
Hi @dlaboss, It's final exam week for me. Sorry for the delay in fixing review comments. |
no worries. hope things go well for you! |
Thanks for your contribution! |
Thank you for your guidance! :) |
No description provided.