router.route("/project").handler(BodyHandler.create()); // Enable body handling
router.post("/project").handler(routingContext -> {
// process the body
JsonObject body = routingContext.getBodyAsJson();
...
But this does doesn't seem to work when there are path paramters:
router.route("/storage").handler(BodyHandler.create()); // Enable body handling
router.post("/storage/p/:projectId/b").handler(routingContext -> {
// process the bodyJsonObject body = routingContext.getBodyAsJson(); // returns null...The POST handler runs, but getBodyAsJson() always returns null. routingContext.body is null.I even tried this without effect:router.route("/").handler(BodyHandler.create()); // Enable body handlingI will next try the "classic" method of a bodyHandler on the request:request.bodyHandler(totalBuffer -> { System.out.println("Full body received, length = " + totalBuffer.length()); });
Using vertx 3.1.0. I know to add a BodyHandler before trying to access the body in a request. This works for paths with no path parameters:router.route("/project").handler(BodyHandler.create()); // Enable body handling router.post("/project").handler(routingContext -> { // process the body JsonObject body = routingContext.getBodyAsJson();...But this does doesn't seem to work when there are path paramters:router.route("/storage").handler(BodyHandler.create()); // Enable body handling
router.post("/storage/p/:projectId/b").handler(routingContext -> { // process the bodyJsonObject body = routingContext.getBodyAsJson(); // returns null...The POST handler runs, but getBodyAsJson() always returns null. routingContext.body is null.I even tried this without effect:router.route("/").handler(BodyHandler.create()); // Enable body handlingI will next try the "classic" method of a bodyHandler on the request:request.bodyHandler(totalBuffer -> { System.out.println("Full body received, length = " + totalBuffer.length()); });
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/9148127d-cea7-4e12-9f77-2dccb4329bdf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.