Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Where NOT to set the router BodyHandler
import io.vertx.core.http.HttpMethod
import io.vertx.groovy.ext.web.Router
import io.vertx.groovy.ext.web.handler.BodyHandler
def router = Router.router(vertx)
router.route().handler(BodyHandler.create()) // This works when defined before the routes
def route = router.route(HttpMethod.POST,"/method")
//router.route().handler(BodyHandler.create()) // This will NOT work
route.handler { routingContext ->
println routingContext.getBodyAsJson()
routingContext.response()
.setStatusCode(200)
.end()
}
vertx.createHttpServer()
.requestHandler(router.&accept)
.listen(8080)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.