-
-
Save lyhcode/6120315 to your computer and use it in GitHub Desktop.
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
/** | |
* HttpBuilder Testing | |
*/ | |
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.2' ) | |
import groovyx.net.http.* | |
import static groovyx.net.http.ContentType.* | |
import static groovyx.net.http.Method.* | |
def http = new HTTPBuilder( 'http://localhost:8080' ) | |
http.request( PUT, JSON ) { | |
uri.path = '/test1/rest/testPut' | |
uri.query = [ v:'1.0', q: 'Calvin and Hobbes' ] | |
body = [ a:1, b:2, c:3 ] | |
headers.'User-Agent' = 'Mozilla/5.0 Ubuntu/8.10 Firefox/3.0.4' | |
response.success = { resp, json -> | |
println resp.statusLine | |
println json.result | |
} | |
response.failure = { resp -> | |
println "Unexpected error: ${resp.statusLine.statusCode} : ${resp.statusLine.reasonPhrase}" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment