router.post("/form").handler(ctx -> { ctx.response().putHeader(HttpHeaders.CONTENT_TYPE, "text/plain");
}); router.post("/access-control-with-post-preflight").handler(ctx -> { HttpServerResponse httpServerResponse = ctx.response(); httpServerResponse.setChunked(true);
router.post("/products").handler(that::handleAddProduct); router.get("/products").handler(that::handleListProducts);
}); router.post("/api/users").handler(ctx -> { JsonObject newUser = ctx.getBodyAsJson();
router.post("/users").handler(ctx -> {
router.post("/form").handler(ctx -> { ctx.response().putHeader("Content-Type", "text/plain");
router.post("/login").handler(ctx -> { JsonObject credentials = ctx.getBodyAsJson(); if (credentials == null) {
final Router router = Router.router(vertex); router.post("/your/endpoint").handler(routingContext -> { routingContext.request().bodyHandler(body -> { System.out.println(body.toString()); }); });
router.post("/chunking_test").handler(createChunkingTestHandler()); router.options("/chunking_test").handler(BaseTransport.createCORSOptionsHandler(options, "OPTIONS, POST"));
@Test public void testRerouteMethod() throws Exception { router.post("/me").handler(ctx -> ctx.response().end("POST")); router.get("/me").handler(ctx -> ctx.reroute(HttpMethod.POST, "/me")); testRequest(HttpMethod.GET, "/me", 200, "OK", "POST"); }
@Test public void testPost() throws Exception { router.post().handler(rc -> rc.response().setStatusMessage("foo").end()); testRequest(HttpMethod.POST, "/whatever", 200, "foo"); testRequest(HttpMethod.GET, "/whatever", 404, "Not Found"); testRequest(HttpMethod.PUT, "/whatever", 404, "Not Found"); testRequest(HttpMethod.DELETE, "/whatever", 404, "Not Found"); testRequest(HttpMethod.OPTIONS, "/whatever", 404, "Not Found"); testRequest(HttpMethod.HEAD, "/whatever", 404, "Not Found"); }
@Test public void testPostWithPathBegin() throws Exception { router.post("/somepath/*").handler(rc -> rc.response().setStatusMessage("foo").end()); testRequest(HttpMethod.POST, "/somepath/whatever", 200, "foo"); testRequest(HttpMethod.POST, "/otherpath/whatever", 404, "Not Found"); testRequest(HttpMethod.GET, "/somepath/whatever", 404, "Not Found"); testRequest(HttpMethod.PUT, "/somepath/whatever", 404, "Not Found"); testRequest(HttpMethod.DELETE, "/somepath/whatever", 404, "Not Found"); testRequest(HttpMethod.OPTIONS, "/somepath/whatever", 404, "Not Found"); testRequest(HttpMethod.HEAD, "/somepath/whatever", 404, "Not Found"); }
@Test public void testPostWithPathExact() throws Exception { router.post("/somepath/").handler(rc -> rc.response().setStatusMessage("foo").end()); testRequest(HttpMethod.POST, "/somepath/", 200, "foo"); testRequest(HttpMethod.POST, "/otherpath/whatever", 404, "Not Found"); testRequest(HttpMethod.GET, "/somepath/whatever", 404, "Not Found"); testRequest(HttpMethod.PUT, "/somepath/whatever", 404, "Not Found"); testRequest(HttpMethod.DELETE, "/somepath/whatever", 404, "Not Found"); testRequest(HttpMethod.OPTIONS, "/somepath/whatever", 404, "Not Found"); testRequest(HttpMethod.HEAD, "/somepath/whatever", 404, "Not Found"); }
/** * Add a route that matches a HTTP POST request and the specified path * @param path URI paths that begin with this path will match * @return the route */ public io.vertx.rxjava.ext.web.Route post(String path) { io.vertx.rxjava.ext.web.Route ret = io.vertx.rxjava.ext.web.Route.newInstance(delegate.post(path)); return ret; }
final Router router = Router.router(vertex); // Adding a BodyHandler for routes router.route().handler(BodyHandler.create()); router.post("/your/endpoint").handler(routingContext -> { System.out.println(routingContext.getBodyAsString()); });
/** * Add a route that matches a HTTP POST request and the specified path * @param path URI paths that begin with this path will match * @return the route */ public io.vertx.rxjava.ext.web.Route post(String path) { io.vertx.rxjava.ext.web.Route ret = io.vertx.rxjava.ext.web.Route.newInstance(delegate.post(path)); return ret; }
@Test public void testRerouteMethod() throws Exception { router.post("/me").handler(ctx -> ctx.response().end("POST")); router.get("/me").handler(ctx -> ctx.reroute(HttpMethod.POST, "/me")); testRequest(HttpMethod.GET, "/me", 200, "OK", "POST"); }
@Test public void testPostWithPathExact() throws Exception { router.post("/somepath/").handler(rc -> rc.response().setStatusMessage("foo").end()); testRequest(HttpMethod.POST, "/somepath/", 200, "foo"); testRequest(HttpMethod.POST, "/otherpath/whatever", 404, "Not Found"); testRequest(HttpMethod.GET, "/somepath/whatever", 404, "Not Found"); testRequest(HttpMethod.PUT, "/somepath/whatever", 404, "Not Found"); testRequest(HttpMethod.DELETE, "/somepath/whatever", 404, "Not Found"); testRequest(HttpMethod.OPTIONS, "/somepath/whatever", 404, "Not Found"); testRequest(HttpMethod.HEAD, "/somepath/whatever", 404, "Not Found"); }
@Test public void testPostWithPathBegin() throws Exception { router.post("/somepath/*").handler(rc -> rc.response().setStatusMessage("foo").end()); testRequest(HttpMethod.POST, "/somepath/whatever", 200, "foo"); testRequest(HttpMethod.POST, "/otherpath/whatever", 404, "Not Found"); testRequest(HttpMethod.GET, "/somepath/whatever", 404, "Not Found"); testRequest(HttpMethod.PUT, "/somepath/whatever", 404, "Not Found"); testRequest(HttpMethod.DELETE, "/somepath/whatever", 404, "Not Found"); testRequest(HttpMethod.OPTIONS, "/somepath/whatever", 404, "Not Found"); testRequest(HttpMethod.HEAD, "/somepath/whatever", 404, "Not Found"); }