Last active
August 29, 2015 14:16
-
-
Save bdkosher/51f9b938f70dbcfa830d to your computer and use it in GitHub Desktop.
A vert.x script to printout information of an HTTP request.
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
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