{"id":6081,"date":"2018-03-30T09:10:35","date_gmt":"2018-03-30T09:10:35","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=6081"},"modified":"2018-03-30T09:10:35","modified_gmt":"2018-03-30T09:10:35","slug":"httpclient-in-vert-x","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/httpclient-in-vert-x\/","title":{"rendered":"HttpClient in Vert.x"},"content":{"rendered":"<p>Vert.x includes an HttpClient and associated code for interacting with HTTP protocols, obviously this can be used to write client applications or in situations where we might use a reference from service discovery.<\/p>\n<p>This is a very short post which is just mean&#8217;t to demonstrate the client capability which will be used in the next post (Service discovery with Vert.x).<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nHttpClient client = vertx.createHttpClient();\r\nclient.getNow(8080, &quot;localhost&quot;, &quot;\/hello&quot;, response -&gt;\r\n{\r\n   response.bodyHandler(\r\n      body -&gt; \r\n         System.out.println(body.toString()));\r\n});\r\n<\/pre>\n<p>The HttpClient gives us get, post, head etc. the <em>Now<\/em> postfixed named methods tend to be simpler syntax including the supply of callback and are composable using fluent style syntax.<\/p>\n<p>See also <a href=\"https:\/\/vertx.io\/docs\/vertx-core\/js\/#_creating_an_http_client\" rel=\"noopener\" target=\"_blank\">Creating an HTTP client<\/a> for more information.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vert.x includes an HttpClient and associated code for interacting with HTTP protocols, obviously this can be used to write client applications or in situations where we might use a reference from service discovery. This is a very short post which is just mean&#8217;t to demonstrate the client capability which will be used in the next [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[161,210],"tags":[],"class_list":["post-6081","post","type-post","status-publish","format-standard","hentry","category-java","category-vert-x"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/6081","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=6081"}],"version-history":[{"count":6,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/6081\/revisions"}],"predecessor-version":[{"id":6094,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/6081\/revisions\/6094"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=6081"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=6081"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=6081"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}