Created
May 1, 2015 22:01
-
-
Save brendonanderson/29049f72954d382d5402 to your computer and use it in GitHub Desktop.
Ratpack Blog - HttpClient Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyRequestService { | |
private HttpClient httpClient | |
@Inject | |
MyRequestService(HttpClient httpClient) { | |
this.httpClient = httpClient | |
} | |
Promise<ReceivedResponse> makeRequest(String uri, String body) { | |
httpClient.request(uri.toURI()) { | |
it.method('POST') | |
.body { | |
it.text(body) | |
} | |
.headers { | |
it.set('X-My-Header', 'xyz') | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment