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

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

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

Route.pathRegex介绍

[英]Set the path prefix as a regular expression. If set then this route will only match request URI paths, the beginning of which match the regex. Only a single path or path regex can be set for a route.
[中]将路径前缀设置为正则表达式。如果设置了,那么该路由将只匹配请求URI路径,其开头与正则表达式匹配。只能为路由设置单个路径或路径正则表达式。

代码示例

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

  1. @Override
  2. public Route optionsWithRegex(String path) {
  3. return route().method(HttpMethod.OPTIONS).pathRegex(path);
  4. }

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

  1. @Override
  2. public Route deleteWithRegex(String path) {
  3. return route().method(HttpMethod.DELETE).pathRegex(path);
  4. }

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

  1. @Override
  2. public Route patchWithRegex(String path) {
  3. return route().method(HttpMethod.PATCH).pathRegex(path);
  4. }

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

  1. @Override
  2. public Route headWithRegex(String path) {
  3. return route().method(HttpMethod.HEAD).pathRegex(path);
  4. }

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

  1. @Override
  2. public Route putWithRegex(String path) {
  3. return route().method(HttpMethod.PUT).pathRegex(path);
  4. }

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

  1. @Override
  2. public Route postWithRegex(String path) {
  3. return route().method(HttpMethod.POST).pathRegex(path);
  4. }

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

  1. @Override
  2. public Route connectWithRegex(String path) {
  3. return route().method(HttpMethod.CONNECT).pathRegex(path);
  4. }

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

  1. @Override
  2. public Route getWithRegex(String path) {
  3. return route().method(HttpMethod.GET).pathRegex(path);
  4. }

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

  1. @Override
  2. public Route traceWithRegex(String path) {
  3. return route().method(HttpMethod.TRACE).pathRegex(path);
  4. }

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

  1. /**
  2. * Set the path prefix as a regular expression. If set then this route will only match request URI paths, the beginning
  3. * of which match the regex. Only a single path or path regex can be set for a route.
  4. * @param path the path regex
  5. * @return a reference to this, so the API can be used fluently
  6. */
  7. public io.vertx.rxjava.ext.web.Route pathRegex(String path) {
  8. delegate.pathRegex(path);
  9. return this;
  10. }

代码示例来源:origin: gentics/mesh

  1. @Override
  2. public InternalEndpointRoute pathRegex(String path) {
  3. this.pathRegex = path;
  4. route.pathRegex(path);
  5. return this;
  6. }

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

  1. /**
  2. * Set the path prefix as a regular expression. If set then this route will only match request URI paths, the beginning
  3. * of which match the regex. Only a single path or path regex can be set for a route.
  4. * @param path the path regex
  5. * @return a reference to this, so the API can be used fluently
  6. */
  7. public io.vertx.rxjava.ext.web.Route pathRegex(String path) {
  8. delegate.pathRegex(path);
  9. return this;
  10. }

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

  1. @Test
  2. public void testSecurityBypass() throws Exception {
  3. Handler<RoutingContext> handler = rc -> {
  4. fail("should not get here");
  5. rc.response().end("Welcome to the protected resource!");
  6. };
  7. JsonObject authConfig = new JsonObject().put("properties_path", "classpath:login/loginusers.properties");
  8. AuthProvider authProvider = ShiroAuth.create(vertx, new ShiroAuthOptions().setType(ShiroAuthRealmType.PROPERTIES).setConfig(authConfig));
  9. router.route().pathRegex("/api/.*").handler(BasicAuthHandler.create(authProvider));
  10. router.route("/api/v1/standard-job-profiles").handler(handler);
  11. testRequest(HttpMethod.GET, "//api/v1/standard-job-profiles", 401, "Unauthorized");
  12. }
  13. }

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

  1. @Test
  2. public void testRegex1WithBuilder() throws Exception {
  3. router.route().pathRegex("\\/([^\\/]+)\\/([^\\/]+)").handler(rc -> {
  4. MultiMap params = rc.request().params();
  5. rc.response().setStatusMessage(params.get("param0") + params.get("param1")).end();
  6. });
  7. testPattern("/dog/cat", "dogcat");
  8. }

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

  1. @Override
  2. public Route getWithRegex(String path) {
  3. return route().method(HttpMethod.GET).pathRegex(path);
  4. }

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

  1. @Override
  2. public Route deleteWithRegex(String path) {
  3. return route().method(HttpMethod.DELETE).pathRegex(path);
  4. }

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

  1. @Override
  2. public Route optionsWithRegex(String path) {
  3. return route().method(HttpMethod.OPTIONS).pathRegex(path);
  4. }

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

  1. @Override
  2. public Route connectWithRegex(String path) {
  3. return route().method(HttpMethod.CONNECT).pathRegex(path);
  4. }

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

  1. @Override
  2. public Route headWithRegex(String path) {
  3. return route().method(HttpMethod.HEAD).pathRegex(path);
  4. }

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

  1. @Test
  2. public void testRegex1WithBuilder() throws Exception {
  3. router.route().pathRegex("\\/([^\\/]+)\\/([^\\/]+)").handler(rc -> {
  4. MultiMap params = rc.request().params();
  5. rc.response().setStatusMessage(params.get("param0") + params.get("param1")).end();
  6. });
  7. testPattern("/dog/cat", "dogcat");
  8. }

相关文章