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

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

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

Route.order介绍

[英]Specify the order for this route. The router tests routes in that order.
[中]指定此路线的顺序。路由器按照这个顺序测试路由。

代码示例

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

/**
 * Specify the order for this route. The router tests routes in that order.
 * @param order the order
 * @return a reference to this, so the API can be used fluently
 */
public io.vertx.rxjava.ext.web.Route order(int order) { 
 delegate.order(order);
 return this;
}

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

@Override
public InternalEndpointRoute order(int order) {
  route.order(order);
  return this;
}

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

/**
 * Specify the order for this route. The router tests routes in that order.
 * @param order the order
 * @return a reference to this, so the API can be used fluently
 */
public io.vertx.rxjava.ext.web.Route order(int order) { 
 delegate.order(order);
 return this;
}

代码示例来源:origin: wang007/vertx-start

@Override
public Route order(int order) {
  return delegate.order(order);
}

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

@Test
public void testOrdering() throws Exception {
 String path = "/blah";
 router.route(path).order(1).handler(rc -> {
  rc.response().write("apples");
  rc.next();
 });
 router.route(path).order(2).handler(rc -> {
  rc.response().write("oranges");
  rc.response().end();
 });
 router.route(path).order(0).handler(rc -> {
  rc.response().setChunked(true);
  rc.response().write("bananas");
  rc.next();
 });
 testRequest(HttpMethod.GET, path, 200, "OK", "bananasapplesoranges");
}

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

@Test
public void testChangeOrderAfterActive2() throws Exception {
 String path = "/blah";
 Route route = router.route(path).failureHandler(rc -> {
  rc.response().write("apples");
  rc.next();
 });
 try {
  route.order(23);
  fail();
 } catch (IllegalStateException e) {
  // OK
 }
}

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

@Test
public void testChangeOrderAfterActive1() throws Exception {
 String path = "/blah";
 Route route = router.route(path).handler(rc -> {
  rc.response().write("apples");
  rc.next();
 });
 try {
  route.order(23);
  fail();
 } catch (IllegalStateException e) {
  // OK
 }
}

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

@Test
public void testCacheNotOverwritingCacheControlHeaderValues() throws Exception {
 router.clear();
 router.route().order(0).handler(context -> {
  context.response().putHeader("cache-control", "test1");
  context.response().putHeader("last-modified", "test2");
  context.response().putHeader("vary", "test3");
  context.next();
 });
 router.route().order(2).handler(stat);
 testRequest(HttpMethod.GET, "/otherpage.html", req -> req.putHeader("accept-encoding", "gzip"), res -> {
  String cacheControl = res.headers().get("cache-control");
  String lastModified = res.headers().get("last-modified");
  String vary = res.headers().get("vary");
  assertEquals("test1", cacheControl);
  assertEquals("test2", lastModified);
  assertEquals("test3", vary);
 }, 200, "OK", "<html><body>Other page</body></html>");
}

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

@Test
public void testIssue176() throws Exception {
 router.route().order(0).handler(context -> {
  context.response().headers().add("X-Here-1", "1");
  context.next();
 });
 router.route().order(0).handler(context -> {
  context.response().headers().add("X-Here-2", "2");
  context.next();
 });
 router.route().handler(context -> {
  context.response().headers().add("X-Here-3", "3");
  context.response().end();
 });
 testRequest(HttpMethod.GET, "/", null, resp -> {
  MultiMap headers = resp.headers();
  assertTrue(headers.contains("X-Here-1"));
  assertTrue(headers.contains("X-Here-2"));
  assertTrue(headers.contains("X-Here-3"));
 }, 200, "OK", null);
}

代码示例来源:origin: zandero/rest.vertx

public static void provide(Router output, ContextProvider<?> provider) {
  output.route().order(ORDER_PROVIDER_HANDLER).handler(getContextHandler(provider));
}

代码示例来源:origin: cn.vertxup/vertx-up

@Override
  public void mount(final Route route,
           final Event event) {
    if (null == event.getMethod()) {
      // Support filter JSR340
      route.path(event.getPath())
          .order(event.getOrder());
    } else {
      route.path(event.getPath())
          .method(event.getMethod())
          .order(event.getOrder());
    }
  }
}

代码示例来源:origin: silentbalanceyh/vertx-zero

@Override
  public void mount(final Router router) {
    /* Breaker and Dispatch **/
    router.route("/*")
        .order(Orders.EVENT)
        .handler(ServiceJet
            .create(this.options)
            .connect(this.vertx)
            .handle());
  }
}

代码示例来源:origin: zandero/rest.vertx

public static void provide(Router output, Class<? extends ContextProvider> provider) {
  try {
    Class clazz = (Class) ClassFactory.getGenericType(provider);
    ContextProvider instance = getContextProviders().getContextProvider(injectionProvider,
                                      clazz,
                                      provider,
                                      null);
    // set before other routes ...
    output.route().order(ORDER_PROVIDER_HANDLER).handler(getContextHandler(instance));
  }
  catch (Throwable e) {
    throw new IllegalArgumentException(e);
  }
}

代码示例来源:origin: silentbalanceyh/vertx-zero

@Override
  public void mount(final Route route,
           final Event event) {
    if (null == event.getMethod()) {
      // Support filter JSR340
      route.path(event.getPath())
          .order(event.getOrder());
    } else {
      route.path(event.getPath())
          .method(event.getMethod())
          .order(event.getOrder());
    }
  }
}

代码示例来源:origin: cn.vertxup/vertx-up

@Override
  public void mount(final Router router) {
    /* Breaker and Dispatch **/
    router.route("/*")
        .order(Orders.EVENT)
        .handler(ServiceJet
            .create(this.options)
            .connect(this.vertx)
            .handle());
  }
}

代码示例来源:origin: silentbalanceyh/vertx-zero

@Override
public void mount(final Router router) {
  // Session Global for Authorzation
  router.route().order(Orders.SESSION).handler(
      SessionHandler.create(LocalSessionStore.create(this.vertx))
  );
  Pool.WALL_MAP.forEach((path, cliffes) -> {
    // 1. Build Handler
    final AuthHandler handler = this.create(this.vertx, cliffes);
    // 2. Path/Order to set Router
    if (null != handler) {
      router.route(path).order(Orders.SECURE).handler(handler)
          .failureHandler(AuthenticateEndurer.create());
    }
    // 3. Wall Advanced, For user data filling.
  });
}

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

@Test
public void testOrdering() throws Exception {
 String path = "/blah";
 router.route(path).order(1).handler(rc -> {
  rc.response().write("apples");
  rc.next();
 });
 router.route(path).order(2).handler(rc -> {
  rc.response().write("oranges");
  rc.response().end();
 });
 router.route(path).order(0).handler(rc -> {
  rc.response().setChunked(true);
  rc.response().write("bananas");
  rc.next();
 });
 testRequest(HttpMethod.GET, path, 200, "OK", "bananasapplesoranges");
}

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

@Test
public void testChangeOrderAfterActive1() throws Exception {
 String path = "/blah";
 Route route = router.route(path).handler(rc -> {
  rc.response().write("apples");
  rc.next();
 });
 try {
  route.order(23);
  fail();
 } catch (IllegalStateException e) {
  // OK
 }
}

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

@Test
public void testChangeOrderAfterActive2() throws Exception {
 String path = "/blah";
 Route route = router.route(path).failureHandler(rc -> {
  rc.response().write("apples");
  rc.next();
 });
 try {
  route.order(23);
  fail();
 } catch (IllegalStateException e) {
  // OK
 }
}

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

@Test
public void testCacheNotOverwritingCacheControlHeaderValues() throws Exception {
 router.clear();
 router.route().order(0).handler(context -> {
  context.response().putHeader("cache-control", "test1");
  context.response().putHeader("last-modified", "test2");
  context.response().putHeader("vary", "test3");
  context.next();
 });
 router.route().order(2).handler(stat);
 testRequest(HttpMethod.GET, "/otherpage.html", req -> req.putHeader("accept-encoding", "gzip"), res -> {
  String cacheControl = res.headers().get("cache-control");
  String lastModified = res.headers().get("last-modified");
  String vary = res.headers().get("vary");
  assertEquals("test1", cacheControl);
  assertEquals("test2", lastModified);
  assertEquals("test3", vary);
 }, 200, "OK", "<html><body>Other page</body></html>");
}

相关文章