Github user dlaboss commented on a diff in the pull request:

    https://github.com/apache/incubator-quarks/pull/106#discussion_r63769266
  
    --- Diff: 
connectors/http/src/main/java/quarks/connectors/http/HttpStreams.java ---
    @@ -38,12 +44,191 @@ Licensed to the Apache Software Foundation (ASF) under 
one
      */
     public class HttpStreams {
         
    +    /**
    +     * Make an HTTP GET request with JsonObject. <br>
    +     * 
    +     * Method specifically works with JsonObjects. For each JsonObject in 
the stream, 
    +     * HTTP GET request is executed on provided uri. As a result, Response 
is added to
    +     * the response TStream.
    +     * <br>
    +     * 
    +     * Sample usage:<br>
    +     * 
    +     * <pre>
    +     * {@code
    +     *     DirectProvider ep = new DirectProvider();
    +     *     Topology topology = ep.newTopology();
    +     *     final String url = "http://httpbin.org/get?";;
    +     * 
    +     *     JsonObject request1 = new JsonObject();
    +     *     request1.addProperty("a", "abc");
    +     *     request1.addProperty("b", "42");
    +     * 
    +     *     TStream<JsonObject> stream = 
topology.collection(Arrays.asList(request1));
    +     *     TStream<JsonObject> rc = HttpStreams.getJson(stream,
    +     *             HttpClients::noAuthentication,
    +     *             t -> url + "a=" + t.get("a").getAsString() + "&b="
    +     *                     + t.get("b").getAsString());
    +     * }
    +     * </pre>
    +     * 
    +     * <br>
    +     * See <i>HttpTest</i> for example. <br>
    +     * 
    +     * @param stream - JsonObject TStream.
    +     * @param clientCreator - CloseableHttpClient supplier preferably 
created using {@link HttpClients}
    +     * @param uri - URI function which returns URI string
    +     * @return TStream of JsonObject which contains responses of GET 
requests
    +     * 
    +     * @see HttpStreams#requests(TStream, Supplier, Function, Function, 
BiFunction)
    +     */
         public static TStream<JsonObject> getJson(TStream<JsonObject> stream,
                 Supplier<CloseableHttpClient> clientCreator,
                 Function<JsonObject,String> uri) {
             
             return HttpStreams.<JsonObject,JsonObject>requests(stream, 
clientCreator,
    -                t -> HttpGet.METHOD_NAME, uri, HttpResponders.json());
    +            t -> HttpGet.METHOD_NAME, uri, HttpResponders.json());
    +    }
    +    
    +    /**
    +     * Make an HTTP DELETE request with JsonObject. <br>
    +     * 
    +     * Method specifically works with JsonObjects. For each JsonObject in 
the
    +     * stream, HTTP DELETE request is executed on provided uri. As a 
result,
    +     * Response is added to the response TStream. <br>
    +     * 
    +     * Sample usage:<br>
    +     * 
    +     * <pre>
    +     * {@code
    +     *     DirectProvider ep = new DirectProvider();
    +     *     Topology topology = ep.newTopology();
    +     *     final String url = "http://httpbin.org/delete?";;
    +     * 
    +     *     JsonObject request = new JsonObject();
    +     *     request.addProperty("a", "abc");
    +     *     request.addProperty("b", "42");
    +     * 
    +     *     TStream<JsonObject> stream = 
topology.collection(Arrays.asList(request));
    +     *     TStream<JsonObject> rc = HttpStreams.deleteJson(stream,
    +     *             HttpClients::noAuthentication,
    +     *             t -> url + "a=" + t.get("a").getAsString() + "&b="
    +     *                     + t.get("b").getAsString());
    +     * }
    +     * </pre>
    +     * 
    +     * <br>
    +     * See <i>HttpTest</i> for example. <br>
    +     * 
    +     * @param stream - JsonObject TStream.
    +     * @param clientCreator - CloseableHttpClient supplier preferably 
created using {@link HttpClients}
    +     * @param uri - URI function which returns URI string
    +     * @return TStream of JsonObject which contains responses of DELETE 
requests
    +     * 
    +     * @see HttpStreams#requests(TStream, Supplier, Function, Function, 
BiFunction)
    +     */
    +    public static TStream<JsonObject> deleteJson(TStream<JsonObject> 
stream,
    +            Supplier<CloseableHttpClient> clientCreator,
    +            Function<JsonObject,String> uri) {
    +        
    +        return HttpStreams.<JsonObject,JsonObject>requests(stream, 
clientCreator,
    +            t -> HttpDelete.METHOD_NAME, uri, HttpResponders.json());
    +    }
    +    
    +    /**
    +     * Make an HTTP POST request with JsonObject. <br>
    +     * 
    +     * Method specifically works with JsonObjects. For each JsonObject in 
the stream, 
    +     * HTTP POST request is executed on provided uri. Request body is 
filled using
    +     * HttpEntity provided by body function. As a result, Response is 
added to
    +     * the response TStream.<br>
    +     * 
    +     * Sample usage:<br>
    +     * 
    +     * <pre>
    +     * {@code
    +     *     DirectProvider ep = new DirectProvider();
    +     *     Topology topology = ep.newTopology();
    +     *     final String url = "http://httpbin.org/post";;
    +     * 
    +     *     JsonObject body = new JsonObject();
    +     *     body.addProperty("foo", "abc");
    +     *     body.addProperty("bar", 42);
    +     * 
    +     *     TStream<JsonObject> stream = 
topology.collection(Arrays.asList(body));
    +     *     TStream<JsonObject> rc = HttpStreams.postJson(stream,
    +     *             HttpClients::noAuthentication, t -> url, t -> body);
    +     * }
    +     * </pre>
    +     * 
    +     * <br>
    +     * See HttpTest for example. <br>
    +     * 
    +     * @param stream - JsonObject TStream.
    +     * @param clientCreator - CloseableHttpClient supplier preferably 
created using {@link HttpClients}
    +     * @param uri - URI function which returns URI string
    +     * @param body - Function that returns HttpEntity which will be set as 
a body for the request.
    +     * @return TStream of JsonObject which contains responses of POST 
requests
    +     * 
    +     * @see HttpStreams#requestsWithBody(TStream, Supplier, Function, 
Function, Function, BiFunction)
    +     */
    +    public static TStream<JsonObject> postJson(TStream<JsonObject> stream,
    +            Supplier<CloseableHttpClient> clientCreator,
    +            Function<JsonObject, String> uri,
    +            UnaryOperator<JsonObject> body) {
    +
    +        return HttpStreams.<JsonObject, JsonObject> 
requestsWithBody(stream,
    +                clientCreator, t -> HttpPost.METHOD_NAME, uri, 
    +                t -> new 
ByteArrayEntity(body.apply(t).toString().getBytes()),
    +                HttpResponders.json());
    +    }
    +    
    +    /**
    +     * Make an HTTP PUT request with JsonObject. <br>
    +     * 
    +     * Method specifically works with JsonObjects. For each JsonObject in 
the
    +     * stream, HTTP PUT request is executed on provided uri. Request body 
is
    +     * filled using HttpEntity provided by body function. As a result, 
Response
    +     * is added to the response TStream.<br>
    +     * 
    +     * Sample usage:<br>
    +     * 
    +     * <pre>
    +     * {@code
    +     *     DirectProvider ep = new DirectProvider();
    +     *     Topology topology = ep.newTopology();
    +     *     final String url = "http://httpbin.org/put";;
    +     * 
    +     *     JsonObject body = new JsonObject();
    +     *     body.addProperty("foo", "abc");
    +     *     body.addProperty("bar", 42);
    +     * 
    +     *     TStream<JsonObject> stream = 
topology.collection(Arrays.asList(body));
    +     *     TStream<JsonObject> rc = HttpStreams.putJson(stream,
    +     *             HttpClients::noAuthentication, t -> url, t -> body);
    --- End diff --
    
    same comment as above for `t -> body` and `@param body` description


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to