Created
June 23, 2016 15:03
-
-
Save abdielou/01b364840f801d8b57f158bb36348b2e to your computer and use it in GitHub Desktop.
Where NOT to set the router BodyHandler
This file contains hidden or 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
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