Skip to content

Instantly share code, notes, and snippets.

@brendonanderson
Created May 1, 2015 22:01
Show Gist options
  • Save brendonanderson/29049f72954d382d5402 to your computer and use it in GitHub Desktop.
Save brendonanderson/29049f72954d382d5402 to your computer and use it in GitHub Desktop.
Ratpack Blog - HttpClient Example
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