Skip to content

Instantly share code, notes, and snippets.

@bdkosher
Last active August 29, 2015 14:16
Show Gist options
  • Save bdkosher/51f9b938f70dbcfa830d to your computer and use it in GitHub Desktop.
Save bdkosher/51f9b938f70dbcfa830d to your computer and use it in GitHub Desktop.
A vert.x script to printout information of an HTTP request.
vertx.createHttpServer().requestHandler { req ->
req.bodyHandler { body ->
def headerInfo = req.headers.entries.collect({ e -> "$e.key : $e.value" }).join('\n')
println """
$req.version $req.method $req.absoluteURI
$headerInfo
"""
if (body) {
println """
=============================
$body
=============================
"""
} else {
println "(No body data)"
}
req.response.statusCode = 204
req.response.end()
}
}.listen(8000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment