当前位置: 首页>>代码示例>>Java>>正文


Java Route类代码示例

本文整理汇总了Java中io.vertx.ext.web.Route的典型用法代码示例。如果您正苦于以下问题:Java Route类的具体用法?Java Route怎么用?Java Route使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Route类属于io.vertx.ext.web包,在下文中一共展示了Route类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHttpServerAndRoutes

import io.vertx.ext.web.Route; //导入依赖的package包/类
private HttpServer getHttpServerAndRoutes(final io.vertx.core.http.HttpServer vertxHttpServer, final Router router) {

        /* Route everything under /v1 to QBit http server. */
        final Route qbitRoute = router.route().path("/v1/*");



        /*
         * Use the VertxHttpServerBuilder which is a special builder for Vertx/Qbit integration.
         */
        return VertxHttpServerBuilder.vertxHttpServerBuilder()
                .setRoute(qbitRoute)
                .setHttpServer(vertxHttpServer)
                .setVertx(getVertx())
                .setConfig(new HttpServerConfig()) //not needed in master branch of qbit workaround for bug
                .build();
    }
 
开发者ID:MammatusTech,项目名称:qbit-microservices-examples,代码行数:18,代码来源:VertxTodoServiceVerticle.java

示例2: logRoutes

import io.vertx.ext.web.Route; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Router logRoutes(Router router) {
  try {
    for (Route route : router.getRoutes()) {
      // path is public but methods are not, we use reflection to make that accessible
      @SuppressWarnings("JavaReflectionMemberAccess")
      Field f = route.getClass().getDeclaredField("methods");
      f.setAccessible(true);
      Set<HttpMethod> methods = (Set<HttpMethod>) f.get(route);
      if (isNotBlank(route.getPath())) {
        methods.forEach(httpMethod -> logger.info("Route: [{}] {}", httpMethod, route.getPath()));
      }
    }
  } catch (Exception ex) {
    logger.info("Could not list a route due to: {}!", ex.getMessage());
  }

  return router;
}
 
开发者ID:glytching,项目名称:dragoman,代码行数:20,代码来源:WebServerVerticle.java

示例3: checkSecurity

import io.vertx.ext.web.Route; //导入依赖的package包/类
private static void checkSecurity(Router router, final RouteDefinition definition) {

		Route route;
		if (definition.pathIsRegEx()) {
			route = router.routeWithRegex(definition.getMethod(), definition.getRoutePath());
		} else {
			route = router.route(definition.getMethod(), definition.getRoutePath());
		}

		route.order(definition.getOrder()); // same order as following handler

		Handler<RoutingContext> securityHandler = getSecurityHandler(definition);
		if (definition.isBlocking()) {
			route.blockingHandler(securityHandler);
		} else {
			route.handler(securityHandler);
		}
	}
 
开发者ID:zandero,项目名称:rest.vertx,代码行数:19,代码来源:RestRouter.java

示例4: rootHandler

import io.vertx.ext.web.Route; //导入依赖的package包/类
/**
 * Handler for the /api endpoint, listing out routes and loaded verticles
 * 
 * @param ctx
 */
private void rootHandler(final RoutingContext ctx) {
	ctx.response().putHeader(Constants.CONTENT_HEADER, Constants.CONTENT_TYPE_JSON);
	final JsonObject result = new JsonObject().put("RunningSince", Utils.getDateString(this.startDate));
	final JsonObject routeObject = new JsonObject();
	for (final Route r : this.router.getRoutes()) {
		final String p = r.getPath();
		if (p != null) {
			routeObject.put(p, String.valueOf(r));
		}
	}
	result.put("Routes", routeObject);
	final JsonArray verticleArray = new JsonArray(this.loadedVerticles);
	result.put("Verticles", verticleArray);
	ctx.response().end(result.encodePrettily());
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:21,代码来源:ApplicationStarter.java

示例5: configureRoute

import io.vertx.ext.web.Route; //导入依赖的package包/类
private static void configureRoute(Route route, Operation operation, EventBus eventBus) {
    Optional.ofNullable(operation.getConsumes()).ifPresent(consumes -> consumes.forEach(route::consumes));
    Optional.ofNullable(operation.getProduces()).ifPresent(produces -> produces.forEach(route::produces));

    route.handler(context -> {
        try {
            JsonObject message = new JsonObject();
            operation.getParameters().forEach( parameter -> {
                String name = parameter.getName();
                String value = PARAMETER_EXTRACTORS.get(parameter.getIn()).extract(name, parameter.getRequired(), context.request());
                message.put(name, value);
            });
            eventBus.<JsonObject>send(operation.getOperationId(), message, operationResponse -> {
                if (operationResponse.succeeded()) {
                    context.response().end(operationResponse.result().body().encode());
                } else {
                    internalServerErrorEnd(context.response());
                }
            });
        } catch (RuntimeException e) {
            badRequestEnd(context.response());
        }
    });
}
 
开发者ID:diega,项目名称:vertx-web-swagger,代码行数:25,代码来源:SwaggerRouter.java

示例6: createRoute

import io.vertx.ext.web.Route; //导入依赖的package包/类
/**
 * Creates the route.
 *
 * @param router the router
 * @param data   the data
 * @return the route
 */
protected Route createRoute(Router router, HandlerData data) {
  Route route = router.route();

  setOrder(data, route);

  if (StringUtils.isNotEmpty(data.httpMethod())) {

    setMethod(data, route);
  }
  if (StringUtils.isNotEmpty(data.path())) {

    setPath(data, route);
  }
  if (StringUtils.isNotEmpty(data.consumes())) {

    setConsumes(data, route);
  }
  if (StringUtils.isNotEmpty(data.produces())) {

    setProduces(data, route);
  }
  return route;
}
 
开发者ID:jspare-projects,项目名称:vertx-jspare,代码行数:31,代码来源:HandlerWrapper.java

示例7: registerEndPoints

import io.vertx.ext.web.Route; //导入依赖的package包/类
@Override
public void registerEndPoints() {
	secureAll();

	// TODO Add method that allows assigning languages from and to the project
	Route createRoute = route("/:projectUuid/languages").method(POST).produces(APPLICATION_JSON);
	createRoute.handler(rc -> {
		throw new NotImplementedException("not implemented");
	});

	Route deleteRoute = route("/:projectUuid/languages").method(DELETE).produces(APPLICATION_JSON);
	deleteRoute.handler(rc -> {
		// Unassign languages should cause a batch process that removes the FieldContainers for the given language.
		throw new NotImplementedException("not implemented");
	});

	Route getRoute = route("/:projectUuid/languages").method(GET).produces(APPLICATION_JSON);
	getRoute.handler(rc -> {
		throw new NotImplementedException("not implemented");
	});
}
 
开发者ID:gentics,项目名称:mesh,代码行数:22,代码来源:LanguageVerticle.java

示例8: testFailureHandler

import io.vertx.ext.web.Route; //导入依赖的package包/类
@Test
public void testFailureHandler() throws Exception {
	RoutingContext rc = mock(RoutingContext.class);
	Route currentRoute = mock(RouteImpl.class);
	when(currentRoute.getPath()).thenReturn("/blub");
	when(rc.currentRoute()).thenReturn(currentRoute);
	ParsedHeaderValues headerValues = mock(ParsedHeaderValues.class);
	when(rc.parsedHeaders()).thenReturn(headerValues);
	HttpServerRequest request = mock(HttpServerRequest.class);
	when(request.query()).thenReturn("?blub");
	when(request.method()).thenReturn(HttpMethod.GET);
	when(request.uri()).thenReturn("");
	when(rc.request()).thenReturn(request);
	when(rc.normalisedPath()).thenReturn("/blub");
	when(rc.queryParams()).thenReturn(new CaseInsensitiveHeaders());
	storage.getRootRouter().handleFailure(rc);
}
 
开发者ID:gentics,项目名称:mesh,代码行数:18,代码来源:RouterStorageTest.java

示例9: prepareHandler

import io.vertx.ext.web.Route; //导入依赖的package包/类
/**
 * Prepare handler.
 *
 * @param router the router
 * @param data the data
 */
public static void prepareHandler(Router router, HandlerData data) {

	log.debug("Mapping handler: {}", data.toStringLine());

	Route route = router.route().order(data.order());

	if (StringUtils.isNotEmpty(data.httpMethod())) {

		setMethod(data, route);
	}
	if (StringUtils.isNotEmpty(data.patch())) {

		setPatch(data, route);
	}
	if (StringUtils.isNotEmpty(data.consumes())) {

		setConsumes(data, route);
	}
	if (StringUtils.isNotEmpty(data.produces())) {

		setProduces(data, route);
	}
	setHandler(data, route);
}
 
开发者ID:jspare-projects,项目名称:jspare-4vertx,代码行数:31,代码来源:HandlerWrapper.java

示例10: initHttpAll

import io.vertx.ext.web.Route; //导入依赖的package包/类
private static void initHttpAll(
    VxmsShared vxmsShared,
    Router router,
    Object service,
    Method restMethod,
    Path path,
    Stream<Method> errorMethodStream,
    Optional<Consumes> consumes) {
  final Optional<Method> errorMethod = errorMethodStream.findFirst();
  final Route route = router.route(URIUtil.cleanPath(path.value()));
  final Vertx vertx = vxmsShared.getVertx();
  final Context context = vertx.getOrCreateContext();
  final String methodId =
      path.value() + HTTP_ALL + ConfigurationUtil.getCircuitBreakerIDPostfix(context.config());
  initHttpRoute(methodId, vxmsShared, service, restMethod, consumes, errorMethod, route);
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:17,代码来源:RESTInitializer.java

示例11: initHttpDelete

import io.vertx.ext.web.Route; //导入依赖的package包/类
private static void initHttpDelete(
    VxmsShared vxmsShared,
    Router router,
    Object service,
    Method restMethod,
    Path path,
    Stream<Method> errorMethodStream,
    Optional<Consumes> consumes) {
  final Route route = router.delete(URIUtil.cleanPath(path.value()));
  final Vertx vertx = vxmsShared.getVertx();
  final Context context = vertx.getOrCreateContext();
  final String methodId =
      path.value()
          + DELETE.class.getName()
          + ConfigurationUtil.getCircuitBreakerIDPostfix(context.config());
  initHttpOperation(
      methodId,
      vxmsShared,
      service,
      restMethod,
      route,
      errorMethodStream,
      consumes,
      DELETE.class);
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:26,代码来源:RESTInitializer.java

示例12: initHttpPut

import io.vertx.ext.web.Route; //导入依赖的package包/类
private static void initHttpPut(
    VxmsShared vxmsShared,
    Router router,
    Object service,
    Method restMethod,
    Path path,
    Stream<Method> errorMethodStream,
    Optional<Consumes> consumes) {
  final Route route = router.put(URIUtil.cleanPath(path.value()));
  final Vertx vertx = vxmsShared.getVertx();
  final Context context = vertx.getOrCreateContext();
  final String methodId =
      path.value()
          + PUT.class.getName()
          + ConfigurationUtil.getCircuitBreakerIDPostfix(context.config());
  initHttpOperation(
      methodId, vxmsShared, service, restMethod, route, errorMethodStream, consumes, PUT.class);
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:19,代码来源:RESTInitializer.java

示例13: initHttpOptions

import io.vertx.ext.web.Route; //导入依赖的package包/类
private static void initHttpOptions(
    VxmsShared vxmsShared,
    Router router,
    Object service,
    Method restMethod,
    Path path,
    Stream<Method> errorMethodStream,
    Optional<Consumes> consumes) {
  final Route route = router.options(URIUtil.cleanPath(path.value()));
  final Vertx vertx = vxmsShared.getVertx();
  final Context context = vertx.getOrCreateContext();
  final String methodId =
      path.value()
          + OPTIONS.class.getName()
          + ConfigurationUtil.getCircuitBreakerIDPostfix(context.config());
  initHttpOperation(
      methodId,
      vxmsShared,
      service,
      restMethod,
      route,
      errorMethodStream,
      consumes,
      OPTIONS.class);
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:26,代码来源:RESTInitializer.java

示例14: initHttpPost

import io.vertx.ext.web.Route; //导入依赖的package包/类
private static void initHttpPost(
    VxmsShared vxmsShared,
    Router router,
    Object service,
    Method restMethod,
    Path path,
    Stream<Method> errorMethodStream,
    Optional<Consumes> consumes) {
  final Route route = router.post(URIUtil.cleanPath(path.value()));
  final Vertx vertx = vxmsShared.getVertx();
  final Context context = vertx.getOrCreateContext();
  final String methodId =
      path.value()
          + POST.class.getName()
          + ConfigurationUtil.getCircuitBreakerIDPostfix(context.config());
  initHttpOperation(
      methodId, vxmsShared, service, restMethod, route, errorMethodStream, consumes, POST.class);
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:19,代码来源:RESTInitializer.java

示例15: initHttpGet

import io.vertx.ext.web.Route; //导入依赖的package包/类
protected static void initHttpGet(
    VxmsShared vxmsShared,
    Router router,
    Object service,
    Method restMethod,
    Path path,
    Stream<Method> errorMethodStream,
    Optional<Consumes> consumes) {
  final Route route = router.get(URIUtil.cleanPath(path.value()));
  final Vertx vertx = vxmsShared.getVertx();
  final Context context = vertx.getOrCreateContext();
  final String methodId =
      path.value()
          + GET.class.getName()
          + ConfigurationUtil.getCircuitBreakerIDPostfix(context.config());
  initHttpOperation(
      methodId, vxmsShared, service, restMethod, route, errorMethodStream, consumes, GET.class);
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:19,代码来源:RESTInitializer.java


注:本文中的io.vertx.ext.web.Route类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。