io.vertx.ext.web.Router.post()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(94)

本文整理了Java中io.vertx.ext.web.Router.post方法的一些代码示例,展示了Router.post的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Router.post方法的具体详情如下:
包路径:io.vertx.ext.web.Router
类名称:Router
方法名:post

Router.post介绍

[英]Add a route that matches any HTTP POST request
[中]添加与任何HTTP POST请求匹配的路由

代码示例

代码示例来源:origin: vert-x3/vertx-examples

router.post("/form").handler(ctx -> {
 ctx.response().putHeader(HttpHeaders.CONTENT_TYPE, "text/plain");

代码示例来源:origin: vert-x3/vertx-examples

});
router.post("/access-control-with-post-preflight").handler(ctx -> {
 HttpServerResponse httpServerResponse = ctx.response();
 httpServerResponse.setChunked(true);

代码示例来源:origin: vert-x3/vertx-examples

router.post("/products").handler(that::handleAddProduct);
router.get("/products").handler(that::handleListProducts);

代码示例来源:origin: vert-x3/vertx-examples

});
router.post("/api/users").handler(ctx -> {
 JsonObject newUser = ctx.getBodyAsJson();

代码示例来源:origin: vert-x3/vertx-examples

router.post("/users").handler(ctx -> {

代码示例来源:origin: vert-x3/vertx-examples

router.post("/form").handler(ctx -> {
 ctx.response().putHeader("Content-Type", "text/plain");

代码示例来源:origin: vert-x3/vertx-examples

.addPathParam("pathParam", ParameterType.FLOAT);
router.post("/hello/:pathParam")
router.post("/jsonUploader")
 .handler(HTTPRequestValidationHandler.create().addJsonBodySchema("{type: string}"))
 .handler((routingContext -> {

代码示例来源:origin: vert-x3/vertx-examples

router.post("/login").handler(ctx -> {
 JsonObject credentials = ctx.getBodyAsJson();
 if (credentials == null) {

代码示例来源:origin: stackoverflow.com

final Router router = Router.router(vertex);
router.post("/your/endpoint").handler(routingContext -> {
 routingContext.request().bodyHandler(body -> {
  System.out.println(body.toString());
 });
});

代码示例来源:origin: vert-x3/vertx-web

router.post("/chunking_test").handler(createChunkingTestHandler());
router.options("/chunking_test").handler(BaseTransport.createCORSOptionsHandler(options, "OPTIONS, POST"));

代码示例来源:origin: vert-x3/vertx-web

@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");
}

代码示例来源:origin: vert-x3/vertx-web

@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");
}

代码示例来源:origin: vert-x3/vertx-web

@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");
}

代码示例来源:origin: vert-x3/vertx-web

@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");
}

代码示例来源:origin: vert-x3/vertx-rx

/**
 * 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;
}

代码示例来源:origin: stackoverflow.com

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());
});

代码示例来源:origin: io.vertx/vertx-rx-java

/**
 * 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;
}

代码示例来源:origin: io.vertx/vertx-web

@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");
}

代码示例来源:origin: io.vertx/vertx-web

@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");
}

代码示例来源:origin: io.vertx/vertx-web

@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");
}

相关文章