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

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

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

Route.path介绍

[英]Set the path prefix for this route. If set then this route will only match request URI paths which start with this path prefix. Only a single path or path regex can be set for a route.
[中]设置此路由的路径前缀。如果设置,则该路由将仅匹配以该路径前缀开头的请求URI路径。只能为路由设置单个路径或路径正则表达式。

代码示例

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

/**
 * Set the path prefix for this route. If set then this route will only match request URI paths which start with this
 * path prefix. Only a single path or path regex can be set for a route.
 * @param path the path prefix
 * @return a reference to this, so the API can be used fluently
 */
public io.vertx.rxjava.ext.web.Route path(String path) { 
 delegate.path(path);
 return this;
}

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

route.path(callbackPath);

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

@Test
public void testInvalidPath() throws Exception {
 try {
  router.route("blah");
  fail();
 } catch (IllegalArgumentException e) {
  // OK
 }
 try {
  router.route().path("blah");
  fail();
 } catch (IllegalArgumentException e) {
  // OK
 }
}

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

@Test
public void testRoutePathBuilderBegin() throws Exception {
 String path = "/blah";
 router.route().path(path + "*").handler(rc -> rc.response().setStatusCode(200).setStatusMessage(rc.request().path()).end());
 testPathBegin(path);
}

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

@Test
public void testPattern1WithBuilder() throws Exception {
 router.route().path("/:abc").handler(rc -> rc.response().setStatusMessage(rc.request().params().get("abc")).end());
 testPattern("/tim", "tim");
}

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

@Test
public void testRoutePathBuilder() throws Exception {
 String path = "/blah";
 router.route().path(path).handler(rc -> rc.response().setStatusCode(200).setStatusMessage(rc.request().path()).end());
 testPathExact(path);
}

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

@Test
public void testInvalidPatternWithBuilder() throws Exception {
 router.route().path("/blah/:!!!/").handler(rc -> {
  MultiMap params = rc.request().params();
  rc.response().setStatusMessage(params.get("!!!")).end();
 });
 testRequest(HttpMethod.GET, "/blah/tim", 404, "Not Found"); // Because it won't match
}

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

@Test
public void testRoutePathAndMethodBuilder() throws Exception {
 String path = "/blah";
 router.route().path(path).method(HttpMethod.GET).handler(rc -> rc.response().setStatusCode(200).setStatusMessage(rc.request().path()).end());
 testPathExact(HttpMethod.GET, path);
 testRequest(HttpMethod.POST, path, 404, "Not Found");
}

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

@Test
public void testRoutePathAndMethodBuilderBegin() throws Exception {
 String path = "/blah";
 router.route().path(path + "*").method(HttpMethod.GET).handler(rc -> rc.response().setStatusCode(200).setStatusMessage(rc.request().path()).end());
 testPathBegin(HttpMethod.GET, path);
 testRequest(HttpMethod.POST, path, 404, "Not Found");
}

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

@Test
public void testRoutePathAndMultipleMethodBuilderBegin() throws Exception {
 String path = "/blah";
 router.route().path(path + "*").method(HttpMethod.GET).method(HttpMethod.POST).handler(rc -> rc.response().setStatusCode(200).setStatusMessage(rc.request().path()).end());
 testPathBegin(HttpMethod.GET, path);
 testPathBegin(HttpMethod.POST, path);
 testRequest(HttpMethod.PUT, path, 404, "Not Found");
}

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

@Test
public void testRoutePathAndMultipleMethodBuilder() throws Exception {
 String path = "/blah";
 router.route().path(path).method(HttpMethod.GET).method(HttpMethod.POST).handler(rc -> rc.response().setStatusCode(200).setStatusMessage(rc.request().path()).end());
 testPathExact(HttpMethod.GET, path);
 testPathExact(HttpMethod.POST, path);
 testRequest(HttpMethod.PUT, path, 404, "Not Found");
}

代码示例来源:origin: advantageous/qbit

final Route qbitRoute = router.route().path("/hello/*");

代码示例来源:origin: advantageous/qbit

final Route qbitRoute = router.route().path("/hello/*");

代码示例来源:origin: advantageous/qbit

});
final Route qbitRoute = router.route().path("/hello/*");

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

private void testRelativeToRoutePath(String pathPrefix) throws Exception {
 TemplateEngine engine = new TestEngine(false);
 router.route().handler(context -> {
  context.put("foo", "badger");
  context.put("bar", "fox");
  context.next();
 });
 Route route = router.route();
 if (pathPrefix != null) {
  route.path(pathPrefix + "*");
 }
 route.handler(TemplateHandler.create(engine, "somedir", "text/html"));
 String expected =
  "<html>\n" +
   "<body>\n" +
   "<h1>Test template</h1>\n" +
   "foo is badger bar is fox<br>\n" +
   "</body>\n" +
   "</html>";
 testRequest(HttpMethod.GET, pathPrefix != null ? pathPrefix + "/test-template.html" : "/test-template.html", 200, "OK", expected);
}

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

@Test
public void testRoutePathBuilderBegin() throws Exception {
 String path = "/blah";
 router.route().path(path + "*").handler(rc -> rc.response().setStatusCode(200).setStatusMessage(rc.request().path()).end());
 testPathBegin(path);
}

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

@Test
public void testRoutePathBuilder() throws Exception {
 String path = "/blah";
 router.route().path(path).handler(rc -> rc.response().setStatusCode(200).setStatusMessage(rc.request().path()).end());
 testPathExact(path);
}

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

@Test
public void testRoutePathAndMethodBuilderBegin() throws Exception {
 String path = "/blah";
 router.route().path(path + "*").method(HttpMethod.GET).handler(rc -> rc.response().setStatusCode(200).setStatusMessage(rc.request().path()).end());
 testPathBegin(HttpMethod.GET, path);
 testRequest(HttpMethod.POST, path, 404, "Not Found");
}

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

@Test
public void testRoutePathAndMultipleMethodBuilderBegin() throws Exception {
 String path = "/blah";
 router.route().path(path + "*").method(HttpMethod.GET).method(HttpMethod.POST).handler(rc -> rc.response().setStatusCode(200).setStatusMessage(rc.request().path()).end());
 testPathBegin(HttpMethod.GET, path);
 testPathBegin(HttpMethod.POST, path);
 testRequest(HttpMethod.PUT, path, 404, "Not Found");
}

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

@Test
public void testRoutePathAndMultipleMethodBuilder() throws Exception {
 String path = "/blah";
 router.route().path(path).method(HttpMethod.GET).method(HttpMethod.POST).handler(rc -> rc.response().setStatusCode(200).setStatusMessage(rc.request().path()).end());
 testPathExact(HttpMethod.GET, path);
 testPathExact(HttpMethod.POST, path);
 testRequest(HttpMethod.PUT, path, 404, "Not Found");
}

相关文章