io.vertx.reactivex.ext.web.Router Java Examples

The following examples show how to use io.vertx.reactivex.ext.web.Router. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UserProfileApiVerticle.java    From vertx-in-action with MIT License 6 votes vote down vote up
@Override
public Completable rxStart() {
  mongoClient = MongoClient.createShared(vertx, mongoConfig());

  authProvider = MongoAuthentication.create(mongoClient, new MongoAuthenticationOptions());
  userUtil = MongoUserUtil.create(mongoClient, new MongoAuthenticationOptions(), new MongoAuthorizationOptions());

  Router router = Router.router(vertx);
  BodyHandler bodyHandler = BodyHandler.create();
  router.post().handler(bodyHandler);
  router.put().handler(bodyHandler);
  router.post("/register")
    .handler(this::validateRegistration)
    .handler(this::register);
  router.get("/:username").handler(this::fetchUser);
  router.put("/:username").handler(this::updateUser);
  router.post("/authenticate").handler(this::authenticate);
  router.get("/owns/:deviceId").handler(this::whoOwns);

  return vertx.createHttpServer()
    .requestHandler(router)
    .rxListen(HTTP_PORT)
    .ignoreElement();
}
 
Example #2
Source File: IngesterVerticle.java    From vertx-in-action with MIT License 6 votes vote down vote up
@Override
public Completable rxStart() {
  updateProducer = KafkaProducer.create(vertx, kafkaConfig());

  AmqpClientOptions amqpOptions = amqpConfig();
  AmqpReceiverOptions receiverOptions = new AmqpReceiverOptions()
    .setAutoAcknowledgement(false)
    .setDurable(true);

  AmqpClient.create(vertx, amqpOptions)
    .rxConnect()
    .flatMap(conn -> conn.rxCreateReceiver("step-events", receiverOptions))
    .flatMapPublisher(AmqpReceiver::toFlowable)
    .doOnError(this::logAmqpError)
    .retryWhen(this::retryLater)
    .subscribe(this::handleAmqpMessage);

  Router router = Router.router(vertx);
  router.post().handler(BodyHandler.create());
  router.post("/ingest").handler(this::httpIngest);

  return vertx.createHttpServer()
    .requestHandler(router)
    .rxListen(HTTP_PORT)
    .ignoreElement();
}
 
Example #3
Source File: RestfulApiVerticle.java    From vertx-blueprint-todo-backend with Apache License 2.0 6 votes vote down vote up
/**
 * Enable CORS support for web router.
 *
 * @param router router instance
 */
protected void enableCorsSupport(Router router) {
  Set<String> allowHeaders = new HashSet<>();
  allowHeaders.add("x-requested-with");
  allowHeaders.add("Access-Control-Allow-Origin");
  allowHeaders.add("origin");
  allowHeaders.add("Content-Type");
  allowHeaders.add("accept");
  // CORS support
  router.route().handler(CorsHandler.create("*")
    .allowedHeaders(allowHeaders)
    .allowedMethod(HttpMethod.GET)
    .allowedMethod(HttpMethod.POST)
    .allowedMethod(HttpMethod.DELETE)
    .allowedMethod(HttpMethod.PATCH)
    .allowedMethod(HttpMethod.PUT)
  );
}
 
Example #4
Source File: RxTodoVerticle.java    From vertx-blueprint-todo-backend with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Future<Void> startFuture) throws Exception {
  Router router = Router.router(vertx);
  // Enable HTTP Body parse.
  router.route().handler(BodyHandler.create());
  // Enable CORS.
  enableCorsSupport(router);

  router.get(Constants.API_GET).handler(this::handleGetTodo);
  router.get(Constants.API_LIST_ALL).handler(this::handleGetAll);
  router.post(Constants.API_CREATE).handler(this::handleCreateTodo);
  router.patch(Constants.API_UPDATE).handler(this::handleUpdateTodo);
  router.delete(Constants.API_DELETE).handler(this::handleDeleteOne);
  router.delete(Constants.API_DELETE_ALL).handler(this::handleDeleteAll);

  String host = config().getString("http.address", HOST);
  int port = config().getInteger("http.port", PORT);

  initService().andThen(createHttpServer(router, host, port))
    .subscribe(startFuture::complete, startFuture::fail);
}
 
Example #5
Source File: AuditVerticle.java    From vertx-kubernetes-workshop with Apache License 2.0 6 votes vote down vote up
private Single<HttpServer> configureTheHTTPServer() {

        //TODO
        //----

        Router router = Router.router(vertx);
        router.get("/").handler(this::retrieveOperations);
        router.get("/health").handler(rc -> {
            if (ready) {
                rc.response().end("Ready");
            } else {
                // Service not yet available
                rc.response().setStatusCode(503).end();
            }
        });
        return vertx.createHttpServer().requestHandler(router::accept).rxListen(8080);
        //----

//        return ready;
    }
 
Example #6
Source File: CurrencyServiceProxy.java    From vertx-kubernetes-workshop with Apache License 2.0 6 votes vote down vote up
@Override
public void start() throws Exception {
    Router router = Router.router(vertx);
    router.get().handler(this::convertPortfolioToEuro);
    router.post().handler(BodyHandler.create());
    router.post().handler(this::delegateWithCircuitBreaker);

    circuit = CircuitBreaker.create("circuit-breaker", vertx,
        new CircuitBreakerOptions()
            .setFallbackOnFailure(true)
            .setMaxFailures(3)
            .setResetTimeout(5000)
            .setTimeout(1000)
    );

    discovery = ServiceDiscovery.create(vertx);


    vertx.createHttpServer()
        .requestHandler(router::accept)
        .listen(8080);
}
 
Example #7
Source File: CurrencyServiceProxy.java    From vertx-kubernetes-workshop with Apache License 2.0 6 votes vote down vote up
@Override
public void start() throws Exception {
    Router router = Router.router(vertx);
    router.get().handler(this::convertPortfolioToEuro);
    router.post().handler(BodyHandler.create());
    router.post().handler(this::delegateWithCircuitBreaker);

    circuit = CircuitBreaker.create("circuit-breaker", vertx,
        new CircuitBreakerOptions()
            .setFallbackOnFailure(true)
            .setMaxFailures(3)
            .setResetTimeout(5000)
            .setTimeout(1000)
    );

    discovery = ServiceDiscovery.create(vertx);


    vertx.createHttpServer()
        .requestHandler(router::accept)
        .listen(8080);
}
 
Example #8
Source File: RxWebApiContractExamples.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
public void mainExample(Vertx vertx, Handler<RoutingContext> myValidationFailureHandler, JWTAuth jwtAuth) {
  OpenAPI3RouterFactory
    .rxCreate(vertx, "src/main/resources/petstore.yaml")
    .flatMap(routerFactory -> {
      // Spec loaded with success. router factory contains OpenAPI3RouterFactory
      // Set router factory options.
      RouterFactoryOptions options = new RouterFactoryOptions().setOperationModelKey("openapi_model");
      // Mount the options
      routerFactory.setOptions(options);
      // Add an handler with operationId
      routerFactory.addHandlerByOperationId("listPets", routingContext -> {
        // Handle listPets operation
        routingContext.response().setStatusMessage("Called listPets").end();
      });

      // Add a security handler
      routerFactory.addSecurityHandler("api_key", JWTAuthHandler.create(jwtAuth));

      // Now you have to generate the router
      Router router = routerFactory.getRouter();

      // Now you can use your Router instance
      HttpServer server = vertx.createHttpServer(new HttpServerOptions().setPort(8080).setHost("localhost"));
      return server.requestHandler(router).rxListen();
    })
    .subscribe(httpServer -> {
      // Server up and running
    }, throwable -> {
      // Error during router factory instantiation or http server start
    });
}
 
Example #9
Source File: DashboardWebAppVerticle.java    From vertx-in-action with MIT License 5 votes vote down vote up
@Override
public Completable rxStart() {
  Router router = Router.router(vertx);

  KafkaConsumer.<String, JsonObject>create(vertx, KafkaConfig.consumerConfig("dashboard-webapp-throughput"))
    .subscribe("event-stats.throughput")
    .toFlowable()
    .subscribe(record -> forwardKafkaRecord(record, "client.updates.throughput"));

  KafkaConsumer.<String, JsonObject>create(vertx, KafkaConfig.consumerConfig("dashboard-webapp-city-trend"))
    .subscribe("event-stats.city-trend.updates")
    .toFlowable()
    .subscribe(record -> forwardKafkaRecord(record, "client.updates.city-trend"));

  KafkaConsumer.<String, JsonObject>create(vertx, KafkaConfig.consumerConfig("dashboard-webapp-ranking"))
    .subscribe("event-stats.user-activity.updates")
    .toFlowable()
    .filter(record -> record.value().getBoolean("makePublic"))
    .buffer(5, TimeUnit.SECONDS, RxHelper.scheduler(vertx))
    .subscribe(this::updatePublicRanking);

  hydrate();

  SockJSHandler sockJSHandler = SockJSHandler.create(vertx);
  SockJSBridgeOptions bridgeOptions = new SockJSBridgeOptions()
    .addInboundPermitted(new PermittedOptions().setAddressRegex("client.updates.*"))
    .addOutboundPermitted(new PermittedOptions().setAddressRegex("client.updates.*"));
  sockJSHandler.bridge(bridgeOptions);
  router.route("/eventbus/*").handler(sockJSHandler);

  router.get("/").handler(ctx -> ctx.reroute("/index.html"));
  router.route().handler(StaticHandler.create("webroot/assets"));

  return vertx.createHttpServer()
    .requestHandler(router)
    .rxListen(HTTP_PORT)
    .ignoreElement();
}
 
Example #10
Source File: DefaultReactor.java    From graviteeio-access-management with Apache License 2.0 5 votes vote down vote up
@Override
public Router unMountSubRouter(String contextPath) {
    router.getRoutes().stream()
            .filter(route -> route.getPath() != null && route.getPath().startsWith(contextPath))
            .forEach(Route::remove);

    return router;
}
 
Example #11
Source File: OAuth2Provider.java    From graviteeio-access-management with Apache License 2.0 5 votes vote down vote up
private void sessionAndCookieHandler(Router router) {
    // OAuth 2.0 Authorization endpoint
    router
            .route("/authorize")
            .handler(cookieHandler)
            .handler(sessionHandler)
            .handler(ssoSessionHandler);
    router
            .route("/consent")
            .handler(cookieHandler)
            .handler(sessionHandler)
            .handler(ssoSessionHandler);
}
 
Example #12
Source File: RootProvider.java    From graviteeio-access-management with Apache License 2.0 5 votes vote down vote up
private void csrfHandler(Router router) {
    router.route("/forgotPassword").handler(csrfHandler);
    router.route("/login").handler(csrfHandler);
    // /login/callback does not need csrf as it is not submit to our server.
    router.route("/login/SSO/POST").handler(csrfHandler);
    router.route("/mfa/challenge").handler(csrfHandler);
    router.route("/mfa/enroll").handler(csrfHandler);
    // /consent csrf is managed by handler-oidc (see OAuth2Provider).
    router.route("/register").handler(csrfHandler);
    router.route("/confirmRegistration").handler(csrfHandler);
    router.route("/resetPassword").handler(csrfHandler);
}
 
Example #13
Source File: DiscoveryProvider.java    From graviteeio-access-management with Apache License 2.0 5 votes vote down vote up
private void startDiscovery() {
    final Router discoveryRouter = Router.router(vertx);

    // UMA Provider configuration information endpoint
    Handler<RoutingContext> providerConfigurationEndpoint = new ProviderConfigurationEndpoint();
    ((ProviderConfigurationEndpoint) providerConfigurationEndpoint).setDiscoveryService(discoveryService);
    discoveryRouter.route().handler(corsHandler);
    discoveryRouter.get().handler(providerConfigurationEndpoint);

    // error handler
    discoveryRouter.route().failureHandler(new ErrorHandler());

    router.mountSubRouter(path(), discoveryRouter);
}
 
Example #14
Source File: UsersProvider.java    From graviteeio-access-management with Apache License 2.0 5 votes vote down vote up
@Override
protected void doStart() throws Exception {
    super.doStart();

    // Create the Users router
    final Router usersRouter = Router.router(vertx);

    final UserConsentsEndpointHandler userConsentsHandler = new UserConsentsEndpointHandler(userService, clientSyncService, domain);
    final UserConsentEndpointHandler userConsentHandler = new UserConsentEndpointHandler(userService, clientSyncService, domain);
    final OAuth2AuthHandler oAuth2AuthHandler = OAuth2AuthHandler.create(oAuth2AuthProvider, "consent_admin");
    oAuth2AuthHandler.extractToken(true);
    oAuth2AuthHandler.selfResource(true, "userId");

    // user consent routes
    usersRouter.routeWithRegex(".*consents.*")
            .pathRegex("\\/(?<userId>[^\\/]+)\\/([^\\/]+)")
            .handler(oAuth2AuthHandler);
    usersRouter.get("/:userId/consents")
            .handler(userConsentsHandler::list);
    usersRouter.delete("/:userId/consents")
            .handler(userConsentsHandler::revoke);
    usersRouter.get("/:userId/consents/:consentId")
            .handler(userConsentHandler::get);
    usersRouter.delete("/:userId/consents/:consentId")
            .handler(userConsentHandler::revoke);

    // error handler
    usersRouter.route().failureHandler(new ErrorHandler());

    router.mountSubRouter(path(), usersRouter);
}
 
Example #15
Source File: Exercise1Verticle.java    From vertx-kubernetes-workshop with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Future<Void> future) throws Exception {
    // Create a simple HTTP service (using Vert.x Web Router) and publish it in the service discovery.
    // As we want to complete the deployment when the service is exposed (asynchronous operation), we use a
    // `Future` argument to indicate when the deployment is completed. This allows deploying the other verticle
    // after the deployment completion of this one.


    // Create an instance of service discovery
    this.discovery = ServiceDiscovery.create(vertx);

    // Simple HTTP API using Vert.x Web Router.
    Router router = Router.router(vertx);
    router.get("/").handler(rc -> rc.response().end("OK"));
    router.get("/greetings").handler(rc -> rc.response().end("Hello world"));
    router.get("/greetings/:name").handler(rc -> rc.response().end("Hello " + rc.pathParam("name")));

    
    vertx.createHttpServer()
        .requestHandler(router::accept)
        .rxListen(8080)
        // When the server is ready, we publish the service
        .flatMap(this::publish)
        // Store the record, required to un-publish it
        .doOnSuccess(rec -> this.record = rec)
        .toCompletable()
        .subscribe(toObserver(future));
}
 
Example #16
Source File: RestApiTestBase.java    From vertx-postgresql-starter with MIT License 5 votes vote down vote up
protected void mockServer(int port, HttpMethod httpMethod, String routingPath, Handler<RoutingContext> handler, TestContext testContext) {
  vertx = new Vertx(rule.vertx());
  router = Router.router(vertx);

  if (httpMethod.equals(HttpMethod.POST) || httpMethod.equals(HttpMethod.PUT)) {
    router.route().handler(BodyHandler.create());
  }

  router.route(httpMethod, routingPath).handler(handler);

  vertx.createHttpServer().requestHandler(router::accept).listen(port, testContext.asyncAssertSuccess());
}
 
Example #17
Source File: ServerExtendableTest.java    From redpipe with Apache License 2.0 5 votes vote down vote up
@Before
public void startVertxWithConfiguredVertxOptions(TestContext context) throws IOException {
    Async async = context.async();

    server = new Server() {
        @Override
        protected @NonNull
        VertxOptions configureVertxOptions(VertxOptions options) {
            return options.setWorkerPoolSize(3);
        }

        @Override
        protected AuthProvider setupAuthenticationRoutes() {
            Router router = AppGlobals.get().getRouter();
            router.get("/test").handler(context -> {
                context.response().end("OK");
            });
            return super.setupAuthenticationRoutes();
        }
    };
    server.start(new JsonObject().put("sessionDisabled", true), TestResource.class, TestResourceRxJava1.class)
            .subscribe(() -> {
                webClient = WebClient.create(server.getVertx(),
                        new WebClientOptions().setDefaultHost("localhost").setDefaultPort(9000));
                async.complete();
            }, x -> {
                x.printStackTrace();
                context.fail(x);
                async.complete();
            });
}
 
Example #18
Source File: UserWebAppVerticle.java    From vertx-in-action with MIT License 5 votes vote down vote up
@Override
public Completable rxStart() {
  Router router = Router.router(vertx);
  router.get("/").handler(ctx -> ctx.reroute("/index.html"));
  router.route().handler(StaticHandler.create("webroot/assets"));
  return vertx.createHttpServer()
    .requestHandler(router)
    .rxListen(HTTP_PORT)
    .ignoreElement();
}
 
Example #19
Source File: ActivityApiVerticle.java    From vertx-in-action with MIT License 5 votes vote down vote up
@Override
public Completable rxStart() {
  pgPool = PgPool.pool(vertx, PgConfig.pgConnectOpts(), new PoolOptions());

  Router router = Router.router(vertx);
  router.get("/:deviceId/total").handler(this::totalSteps);
  router.get("/:deviceId/:year/:month").handler(this::stepsOnMonth);
  router.get("/:deviceId/:year/:month/:day").handler(this::stepsOnDay);
  router.get("/ranking-last-24-hours").handler(this::ranking);

  return vertx.createHttpServer()
    .requestHandler(router)
    .rxListen(HTTP_PORT)
    .ignoreElement();
}
 
Example #20
Source File: FakeUserService.java    From vertx-in-action with MIT License 5 votes vote down vote up
@Override
public Completable rxStart() {
  Router router = Router.router(vertx);
  router.get("/owns/:deviceId").handler(this::owns);
  router.get("/:username").handler(this::username);
  return vertx.createHttpServer()
    .requestHandler(router)
    .rxListen(3000)
    .ignoreElement();
}
 
Example #21
Source File: FakeUserService.java    From vertx-in-action with MIT License 5 votes vote down vote up
@Override
public Completable rxStart() {
  Router router = Router.router(vertx);
  router.get("/owns/:deviceId").handler(this::owns);
  router.get("/:username").handler(this::username);
  return vertx.createHttpServer()
    .requestHandler(router)
    .rxListen(3000)
    .ignoreElement();
}
 
Example #22
Source File: SuperHeroesService.java    From rxjava2-lab with Apache License 2.0 5 votes vote down vote up
public Completable start() {
    Vertx vertx = Vertx.vertx();

    Router router = Router.router(vertx);
    router.get("/heroes").handler(this::getAllHeroes);
    router.get("/villains").handler(this::getAllVillains);
    router.get("/heroes/random").handler(this::getRandomHero);
    router.get("/heroes/:id").handler(this::getHeroById);
    router.get("/villains/random").handler(this::getRandomVillain);
    router.get("/villains/:id").handler(this::getVillainById);

    return vertx.fileSystem().rxReadFile("src/main/resources/characters.json")
        .map(buffer -> buffer.toJsonArray().stream().map(o -> new Character((JsonObject) o)).collect(Collectors.toList()))
        .doOnSuccess(list -> {
            if (verbose) {
                System.out.println("Loaded " + list.size() + " heroes and villains");
            }
        })
        .doOnSuccess(list -> {
            this.villains = list.stream().filter(Character::isVillain).collect(
                HashMap::new, (map, superStuff) -> map.put(superStuff.getId(), superStuff), HashMap::putAll);
            this.heroes = list.stream().filter(e -> ! e.isVillain()).collect(
                HashMap::new, (map, superStuff) -> map.put(superStuff.getId(), superStuff), HashMap::putAll);
        })
        .flatMap(x -> vertx.createHttpServer()
            .requestHandler(router::accept)
            .rxListen(8080))
        .toCompletable();

}
 
Example #23
Source File: HttpServerVerticle.java    From vertx-postgresql-starter with MIT License 5 votes vote down vote up
@Override
public void start(Future<Void> startFuture) throws Exception {
  HttpServer httpServer = vertx.createHttpServer();

  BookDatabaseService bookDatabaseService = createProxy(vertx.getDelegate(), config().getString(CONFIG_DB_EB_QUEUE));

  Router router = Router.router(vertx);

  router.route().handler(BodyHandler.create());

  router.route().handler(HTTPRequestValidationHandler.create().addExpectedContentType("application/json"));

  router.get(GET_BOOKS).handler(addBookValidationHandler())
    .handler(BookApis.getBooksHandler(bookDatabaseService));

  router.post(ADD_NEW_BOOK).handler(BookApis.addBookHandler(bookDatabaseService));

  router.delete(DELETE_BOOK_BY_ID).handler(deleteBookByIdValidationHandler())
    .handler(BookApis.deleteBookByIdHandler(bookDatabaseService));

  router.get(GET_BOOK_BY_ID).handler(getBookByIdValidationHandler())
    .handler(BookApis.getBookByIdHandler(bookDatabaseService));

  router.put(UPDATE_BOOK_BY_ID).handler(upsertBookByIdValidationHandler())
    .handler(BookApis.upsertBookByIdHandler(bookDatabaseService));

  router.route().failureHandler(new FailureHandler());

  int httpServerPort = config().getInteger(CONFIG_HTTP_SERVER_PORT, 8080);
  httpServer.requestHandler(router::accept)
    .rxListen(httpServerPort)
    .subscribe(server -> {
        LOGGER.info("HTTP server is running on port " + httpServerPort);
        startFuture.complete();
      },
      throwable -> {
        LOGGER.error("Fail to start a HTTP server ", throwable);
        startFuture.fail(throwable);
      });
}
 
Example #24
Source File: WikiServer.java    From redpipe with Apache License 2.0 5 votes vote down vote up
@Override
protected AuthProvider setupAuthenticationRoutes() {
	JsonObject keycloackConfig = AppGlobals.get().getConfig().getJsonObject("keycloack");
	OAuth2Auth authWeb = KeycloakAuth.create(AppGlobals.get().getVertx(), keycloackConfig);
	OAuth2Auth authApi = KeycloakAuth.create(AppGlobals.get().getVertx(), OAuth2FlowType.PASSWORD, keycloackConfig);
	
	// FIXME: URL
	OAuth2AuthHandler authHandler = OAuth2AuthHandler.create((OAuth2Auth) authWeb, "http://localhost:9000/callback");
	Router router = AppGlobals.get().getRouter();
	// FIXME: crazy!!
	AuthProvider authProvider = AuthProvider.newInstance(authWeb.getDelegate());
	router.route().handler(UserSessionHandler.create(authProvider));

	authHandler.setupCallback(router.get("/callback"));
	
	JWTAuth jwtAuth = JWTAuth.create(AppGlobals.get().getVertx(), new JWTAuthOptions(new JsonObject()
			.put("keyStore", AppGlobals.get().getConfig().getJsonObject("keystore"))));
	AppGlobals.get().setGlobal(JWTAuth.class, jwtAuth);
	
	JWTAuthHandler jwtAuthHandler = JWTAuthHandler.create(jwtAuth, "/wiki/api/token");

	// FIXME: just use different routers
	router.route().handler(ctx -> {
		if(!ctx.request().uri().startsWith("/wiki/api/"))
			authHandler.handle(ctx);
		else
			jwtAuthHandler.handle(ctx);
	});
	
	return AuthProvider.newInstance(authApi.getDelegate());
}
 
Example #25
Source File: Server.java    From redpipe with Apache License 2.0 5 votes vote down vote up
private Completable startVertx(VertxResteasyDeployment deployment)
{
	return Completable.defer(() -> {
		Router router = Router.router(vertx);
		AppGlobals globals = AppGlobals.get();
		globals.setRouter(router);

		VertxPluginRequestHandler resteasyHandler = new VertxPluginRequestHandler(vertx, deployment, plugins);

		return doOnPlugins(plugin -> plugin.preRoute())
				.doOnComplete(() -> {
					setupRoutes(router);
					router.route().handler(routingContext -> {
						ResteasyProviderFactory.pushContext(RoutingContext.class, routingContext);
						ResteasyProviderFactory.pushContext(io.vertx.rxjava.ext.web.RoutingContext.class, 
								io.vertx.rxjava.ext.web.RoutingContext.newInstance(routingContext.getDelegate()));
						resteasyHandler.handle(routingContext.request());
					});
				}).concatWith(doOnPlugins(plugin -> plugin.postRoute()))
				.concatWith(Completable.defer(() -> {
					// Start the front end server using the Jax-RS controller
					int port = globals.getConfig().getInteger("http_port", 9000);
					String host = globals.getConfig().getString("http_host", NetServerOptions.DEFAULT_HOST);
					return vertx.createHttpServer()
							.requestHandler(router::accept)
							.rxListen(port, host)
							.doOnSuccess(server -> System.out.println("Server started on port " + server.actualPort()))
							.doOnError(t -> t.printStackTrace())
							.ignoreElement();
				}));
	});
}
 
Example #26
Source File: MyFirstVerticle.java    From introduction-to-eclipse-vertx with Apache License 2.0 5 votes vote down vote up
private Completable createHttpServer(JsonObject config, Router router) {
    return vertx
        .createHttpServer()
        .requestHandler(router::accept)
        .rxListen(config.getInteger("HTTP_PORT", 8080))
        .toCompletable();
}
 
Example #27
Source File: UMAProvider.java    From graviteeio-access-management with Apache License 2.0 4 votes vote down vote up
private void errorHandler(Router router) {
    router.route().failureHandler(new UmaExceptionHandler());
}
 
Example #28
Source File: DefaultReactor.java    From graviteeio-access-management with Apache License 2.0 4 votes vote down vote up
@Override
public void afterPropertiesSet() {
    router = Router.router(vertx);
    router.route().handler(transactionHandlerFactory.create());
    router.route().last().handler(context -> sendNotFound(context.response()));
}
 
Example #29
Source File: AppGlobals.java    From redpipe with Apache License 2.0 4 votes vote down vote up
public Router getRouter() {
	return router;
}
 
Example #30
Source File: DefaultReactor.java    From graviteeio-access-management with Apache License 2.0 4 votes vote down vote up
@Override
public Router mountSubRouter(String contextPath, Router child) {
    router.mountSubRouter(contextPath, child);

    return router;
}