Created
July 14, 2014 14:19
-
-
Save beckje01/30c886df1189f3d2dea7 to your computer and use it in GitHub Desktop.
HttpClient Proxy Scratch
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
get { HttpClient httpClient -> | |
def result = httpClient.request("http://beckje01.com", { RequestSpec requestSpec -> | |
requestSpec.body.type("text/plain").stream { it << request.body.text } | |
requestSpec.method(request.method.toString()) | |
request.headers.getNames().each { | |
requestSpec.headers.set(it, request.headers.get(it)) | |
} | |
}) | |
result.onError({ | |
println it | |
context.render("Error!") | |
}).then({ | |
context.render("Working: "+it.body.text) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment