Java Code Examples for io.vertx.ext.web.Router#router()

The following examples show how to use io.vertx.ext.web.Router#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: ApiVerticle.java    From gushici with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void start(Future<Void> startFuture) {
    Router router = Router.router(vertx);
    router.route().handler(BodyHandler.create());
    router.get("/*").handler(this::log); // 全局日志处理,会执行 next() 到下一个
    router.get("/").handler(this::handleRoot); // 首页
    router.get("/favicon.ico").handler(c -> c.fail(404)); // 针对浏览器返回404
    router.get("/log").handler(this::showLog); // 显示日志
    router.routeWithRegex("/([a-z0-9/]*)\\.?(txt|json|png|svg|)")
        .handler(this::handleGushici); // 核心API调用
    router.route().last().handler(c -> c.fail(404)) // 其他返回404
        .failureHandler(this::returnError); // 对上面所有的错误进行处理
    vertx
        .createHttpServer()
        .requestHandler(router)
        .listen(
            config().getInteger("http.port", 8080),
            result -> {
                if (result.succeeded()) {
                    startFuture.complete();
                } else {
                    startFuture.fail(result.cause());
                }
            }
        );
}
 
Example 2
Source File: HttpApplication.java    From jkube with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void start(Future<Void> future) {
    // Create a router object.
    Router router = Router.router(vertx);

    router.get("/api/greeting").handler(this::greeting);
    router.get("/*").handler(StaticHandler.create());

    // Create the HTTP server and pass the "accept" method to the request handler.
    vertx
            .createHttpServer()
            .requestHandler(router::accept)
            .listen(
                    // Retrieve the port from the configuration, default to 8080.
                    config().getInteger("http.port", 8080), ar -> {
                        if (ar.succeeded()) {
                            System.out.println("Server starter on port " + ar.result().actualPort());
                        }
                        future.handle(ar.mapEmpty());
                    });

}
 
Example 3
Source File: ServerBootstrap.java    From vertxui with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void start() {
	// Fake initial data
	bills.all = new ArrayList<>();
	Bill bill = new Bill(Name.Niels, 55, "Weekend shopping", new Date());
	bills.all.add(bill);
	grocery.all = new ArrayList<>();
	grocery.all.add("Chocolate milk");

	// Route all URLs
	Router router = Router.router(vertx);
	router.get(Store.totalsUrl).handler(Pojofy.ajax(null, this::getTotals));
	router.get(Store.billsUrl).handler(Pojofy.ajax(null, this::getBills));
	router.post(Store.billsUrl).handler(Pojofy.ajax(Bill.class, this::addBill));

	router.get(Store.groceryUrl).handler(Pojofy.ajax(null, this::getGrocery));
	router.post(Store.groceryUrl).handler(Pojofy.ajax(null, this::addGrocery));
	router.delete(Store.groceryUrl).handler(Pojofy.ajax(null, this::delGrocery));

	AllExamplesServer.start(View.class, router);
}
 
Example 4
Source File: ExampleHelloWorldFluent.java    From vertxui with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void start() {

	// Wait and do some server stuff for AJAX
	Router router = Router.router(vertx);
	router.post(Client.url).handler(Pojofy.ajax(String.class, (dto, context) -> {
		// Without timer, write 'return "Hello,".....' because strings are
		// returned as is.
		vertx.setTimer(1000, l -> {
			context.response().putHeader("Content-Type", "text/plain; charset=" + VertxUI.charset);
			context.response().end("Hello, " + context.request().getHeader("User-Agent"));
		});
		return null; // null means: we take care of the request() ourselves
	}));

	// extra: pojo example. Here the Pojofy.ajax() makes more sense!
	router.post(Client.urlPojo).handler(Pojofy.ajax(Dto.class, (dto, context) -> {
		log.info("Received a pojo from the client: color=" + dto.color);
		return new Dto("purple");
	}));

	AllExamplesServer.start(Client.class, router);
}
 
Example 5
Source File: CircuitBreakerExamples.java    From vertx-circuit-breaker with Apache License 2.0 6 votes vote down vote up
public void example7(Vertx vertx) {
  // Create the circuit breaker as usual.
  CircuitBreaker breaker = CircuitBreaker.create("my-circuit-breaker", vertx);
  CircuitBreaker breaker2 = CircuitBreaker.create("my-second-circuit-breaker", vertx);

  // Create a Vert.x Web router
  Router router = Router.router(vertx);
  // Register the metric handler
  router.get("/hystrix-metrics").handler(HystrixMetricHandler.create(vertx));

  // Create the HTTP server using the router to dispatch the requests
  vertx.createHttpServer()
    .requestHandler(router)
    .listen(8080);

}
 
Example 6
Source File: AuditVerticle.java    From microtrader with MIT License 6 votes vote down vote up
private Future<HttpServer> configureTheHTTPServer() {
    Future<HttpServer> future = Future.future();

    // Use a Vert.x Web router for this REST API.
    Router router = Router.router(vertx);
    router.get(config.getString("http.root")).handler(context -> {
        Future<List<JsonObject>> jdbcFuture = retrieveOperations();
        jdbcFuture.setHandler(jdbc -> {
            if (jdbc.succeeded()) {
                context.response()
                        .putHeader("Content-Type", "application/json")
                        .setStatusCode(200)
                        .end(Json.encodePrettily(jdbcFuture.result()));
            } else {
                context.response().setStatusCode(500).end(jdbc.cause().toString());
            }
        });
    });

    vertx.createHttpServer()
            .requestHandler(router::accept)
            .listen(config.getInt("http.port"), future.completer());

    return future;
}
 
Example 7
Source File: RouteWithContextTest.java    From rest.vertx with Apache License 2.0 5 votes vote down vote up
@BeforeAll
static void start() {

    before();

    Router router = Router.router(vertx);
    router.route().handler(pushContextHandler());

    RestRouter.register(router, TestContextRest.class);
    vertx.createHttpServer()
            .requestHandler(router)
            .listen(PORT);
}
 
Example 8
Source File: RestKiqrServerVerticle.java    From kiqr with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Future<Void> fut) throws Exception {

    LOG.info("Starting KafkaStreams and Webserver");
    Future runtimeVerticleCompleter = Future.future();
    vertx.deployVerticle(runtimeVerticle, runtimeVerticleCompleter.completer());

    // Create a router object.
    Router router = Router.router(vertx);

    addRouteForMultiValuedKVQueries(router);
    addRouteForScalarKVQueries(router);

    addRouteForWindowQueries(router);
    addRouteForKVCountQueries(router);
    addRouteForSessionQueries(router);

    Future serverListener = Future.future();

    int port = vertx
            .createHttpServer(serverOptions)
            .requestHandler(router::accept)
            .listen(serverListener.completer())
            .actualPort();


    CompositeFuture.all(runtimeVerticleCompleter, serverListener).setHandler(handler -> {
        if (handler.succeeded()) {
            LOG.info("Started KafkaStreams and Webserver, listening on port " + port);
            fut.complete();
        } else {
            LOG.error("Failure during startup", handler.cause());
            fut.fail(handler.cause());
        }
    });
}
 
Example 9
Source File: VertxHttpRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public static void startServerAfterFailedStart() {
    if (closeTask != null) {
        //it is possible start failed after the server was started
        //we shut it down in this case, as we have no idea what state it is in
        final Handler<RoutingContext> prevHotReplacementHandler = hotReplacementHandler;
        shutDownDevMode();
        // reset back to the older hot replacement handler, so that it can be used
        // to watch any artifacts that need hot deployment to fix the reason which caused
        // the server start to fail
        hotReplacementHandler = prevHotReplacementHandler;
    }
    VertxConfiguration vertxConfiguration = new VertxConfiguration();
    ConfigInstantiator.handleObject(vertxConfiguration);
    Vertx vertx = VertxCoreRecorder.initialize(vertxConfiguration, null);

    try {
        HttpBuildTimeConfig buildConfig = new HttpBuildTimeConfig();
        ConfigInstantiator.handleObject(buildConfig);
        HttpConfiguration config = new HttpConfiguration();
        ConfigInstantiator.handleObject(config);
        Router router = Router.router(vertx);
        if (hotReplacementHandler != null) {
            router.route().order(Integer.MIN_VALUE).blockingHandler(hotReplacementHandler);
        }
        rootHandler = router;

        //we can't really do
        doServerStart(vertx, buildConfig, config, LaunchMode.DEVELOPMENT, new Supplier<Integer>() {
            @Override
            public Integer get() {
                return ProcessorInfo.availableProcessors() * 2; //this is dev mode, so the number of IO threads not always being 100% correct does not really matter in this case
            }
        }, null);

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 10
Source File: HystrixDashboardVerticle.java    From standalone-hystrix-dashboard with MIT License 5 votes vote down vote up
/**
 * Create the routes for dashboard app
 *
 * @return A {@link Router} with all the routes needed for the app.
 */
private Router createRoutes() {
  final Router hystrixRouter = Router.router(vertx);

  // proxy stream handler
  hystrixRouter.get("/proxy.stream").handler(HystrixDashboardProxyConnectionHandler.create());

  // proxy the eureka apps listing
  hystrixRouter.get("/eureka").handler(HystrixDashboardProxyEurekaAppsListingHandler.create(vertx));

  hystrixRouter.route("/*")
               .handler(StaticHandler.create()
                                     .setCachingEnabled(true)
                                     .setCacheEntryTimeout(1000L * 60 * 60 * 24));

  final Router mainRouter = Router.router(vertx);

  // if send a route without the trailing '/' some problems will occur, so i redirect the guy using the trailing '/'
  mainRouter.route("/hystrix-dashboard")
            .handler(context -> {
              if (context.request().path().endsWith("/")) {
                context.next();
              } else {
                context.response()
                       .setStatusCode(HttpResponseStatus.MOVED_PERMANENTLY.code())
                       .putHeader(HttpHeaders.LOCATION, "/hystrix-dashboard/")
                       .end();
              }
            });

  mainRouter.mountSubRouter("/hystrix-dashboard", hystrixRouter);
  return mainRouter;
}
 
Example 11
Source File: Testverticle.java    From vxms with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Future<Void> startFuture) throws Exception {
  final HttpServer localhost =
      vertx.createHttpServer(new HttpServerOptions().setHost("localhost").setPort(8080));
  final Router router = Router.router(vertx);
  router
      .get("/test")
      .handler(
          handler -> {
            handler.response().end("hello");
          });
  localhost.requestHandler(router::accept).listen();
  startFuture.complete();
}
 
Example 12
Source File: SimpleWebVerticle.java    From jkube with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void start(Future<Void> startFuture) throws Exception {
    Router router = Router.router(vertx);

    router.get("/").handler(this::handleGet);

    vertx.createHttpServer().requestHandler(router::accept).listen(8080, ar -> {
        if (ar.succeeded()) {
            startFuture.complete();
        } else {
            startFuture.fail(ar.cause());
        }
    });
}
 
Example 13
Source File: MetadataHandlerTest.java    From vertx-starter with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReturnStarterMetadata(Vertx vertx, VertxTestContext testContext) throws IOException {
  JsonObject starterData = Util.loadStarterData();

  JsonObject defaults = starterData.getJsonObject("defaults");
  JsonArray versions = starterData.getJsonArray("versions");
  JsonArray stack = starterData.getJsonArray("stack");

  Router router = Router.router(vertx);
  router.route().handler(new MetadataHandler(defaults, versions, stack));

  vertx.createHttpServer(new HttpServerOptions().setPort(0))
    .requestHandler(router)
    .listen(testContext.succeeding(server -> {

      WebClient webClient = WebClient.create(vertx, new WebClientOptions().setDefaultPort(server.actualPort()));
      webClient.get("/")
        .send(testContext.succeeding(response -> testContext.verify(() -> {

          assertThat(response.statusCode()).withFailMessage(response.bodyAsString()).isEqualTo(200);

          JsonObject metadata = response.bodyAsJsonObject();
          assertThat(metadata.getJsonObject("defaults")).isEqualTo(defaults);
          assertThat(metadata.getJsonArray("versions")).isEqualTo(versions);
          assertThat(metadata.getJsonArray("stack")).isEqualTo(stack);
          assertThat(metadata.getJsonArray("buildTools")).contains("maven", "gradle");
          assertThat(metadata.getJsonArray("languages")).contains("java", "kotlin");
          assertThat(metadata.getJsonArray("jdkVersions")).contains("1.8", "11", "13");
          assertThat(metadata.getJsonArray("vertxDependencies")).isEqualTo(stack);
          assertThat(metadata.getJsonArray("vertxVersions")).isEqualTo(versions.stream()
            .map(JsonObject.class::cast)
            .map(obj -> obj.getString("number"))
            .collect(JsonArray::new, JsonArray::add, JsonArray::addAll));

          testContext.completeNow();

        })));
    }));
}
 
Example 14
Source File: ShoppingUIVerticle.java    From vertx-blueprint-microservice with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Future<Void> future) throws Exception {
  super.start();
  Router router = Router.router(vertx);

  // event bus bridge
  SockJSHandler sockJSHandler = SockJSHandler.create(vertx);
  router.route("/eventbus/*").handler(sockJSHandler);

  // static content
  router.route("/*").handler(StaticHandler.create());

  // get HTTP host and port from configuration, or use default value
  String host = config().getString("shopping.ui.http.address", "0.0.0.0");
  int port = config().getInteger("shopping.ui.http.port", 8080);

  // create HTTP server
  vertx.createHttpServer()
    .requestHandler(router::accept)
    .listen(port, ar -> {
      if (ar.succeeded()) {
        future.complete();
        logger.info(String.format("Shopping UI service is running at %d", port));
      } else {
        future.fail(ar.cause());
      }
    });
}
 
Example 15
Source File: MainVerticle.java    From vertx-in-production with MIT License 5 votes vote down vote up
@Override
public void start() {
    configureLogging();

    this.pingHandler = new PingHandler();
    this.failureHandler = new FailureHandler();
    this.pokemonHandler = new PokemonHandler(vertx);
    this.greetingHandler = new GreetingHandler();

    configureRouteHandlers(config());
    configureEventBus();
    HealthChecks healthChecks = pokemonHandler.getHealthchecks();

    HTTPRequestValidationHandler greetingValidationHandler = HTTPRequestValidationHandler
            .create()
            .addHeaderParam("Authorization", ParameterType.GENERIC_STRING, true)
            .addHeaderParam("Version", ParameterType.INT, true)
            .addPathParamWithCustomTypeValidator("name", new NameValidator(), false);

    Router router = Router.router(vertx);
    router.route().consumes("application/json");
    router.route().produces("application/json");
    router.route().handler(BodyHandler.create());

    router.get("/ping").handler(pingHandler).failureHandler(failureHandler);
    router.get("/pokemons").handler(pokemonHandler).failureHandler(failureHandler);

    router.get("/greetings/:name")
            .handler(greetingValidationHandler)
            .handler(greetingHandler)
            .failureHandler(failureHandler);

    router.get("/alive").handler(HealthCheckHandler.create(vertx));
    router.get("/healthy").handler(HealthCheckHandler.createWithHealthChecks(healthChecks));

    vertx.createHttpServer().requestHandler(router).listen(8080);
}
 
Example 16
Source File: WechatMessageSubRouter.java    From AlipayWechatPlatform with GNU General Public License v3.0 4 votes vote down vote up
private WechatMessageSubRouter(){
    wxMsgRouter = Router.router(vertx);
    wxMsgRouter.put("/kf").handler(this::sendCustomerServiceMessage);
    wxMsgRouter.put("/tp").handler(this::sendTemplateMessage);
}
 
Example 17
Source File: LoginSubRouter.java    From AlipayWechatPlatform with GNU General Public License v3.0 4 votes vote down vote up
private LoginSubRouter(JWTAuth jwtProvider) {
    this.provider = jwtProvider;
    loginRouter = Router.router(vertx);
    loginRouter.post("/").handler(this::login);
    loginRouter.post("/reg").handler(this::register);
}
 
Example 18
Source File: VxApiApplication.java    From VX-API-Gateway with MIT License 4 votes vote down vote up
/**
 * 创建https服务器
 * 
 * @param createHttp
 */
public void createHttpsServer(Handler<AsyncResult<Void>> createHttps) {
	this.httpsRouter = Router.router(vertx);
	httpsRouter.route().handler(this::filterBlackIP);
	httpsRouter.route().handler(CookieHandler.create());
	SessionStore sessionStore = null;
	if (vertx.isClustered()) {
		sessionStore = ClusteredSessionStore.create(vertx);
	} else {
		sessionStore = LocalSessionStore.create(vertx);
	}
	SessionHandler sessionHandler = SessionHandler.create(sessionStore);
	sessionHandler.setSessionCookieName(appOption.getSessionCookieName());
	sessionHandler.setSessionTimeout(appOption.getSessionTimeOut());
	httpsRouter.route().handler(sessionHandler);
	// 跨域处理
	if (corsOptions != null) {
		CorsHandler corsHandler = CorsHandler.create(corsOptions.getAllowedOrigin());
		if (corsOptions.getAllowedHeaders() != null) {
			corsHandler.allowedHeaders(corsOptions.getAllowedHeaders());
		}
		corsHandler.allowCredentials(corsOptions.isAllowCredentials());
		if (corsOptions.getExposedHeaders() != null) {
			corsHandler.exposedHeaders(corsOptions.getExposedHeaders());
		}
		if (corsOptions.getAllowedMethods() != null) {
			corsHandler.allowedMethods(corsOptions.getAllowedMethods());
		}
		corsHandler.maxAgeSeconds(corsOptions.getMaxAgeSeconds());
		httpsRouter.route().handler(corsHandler);
	}
	// 创建https服务器
	serverOptions.setSsl(true);
	VxApiCertOptions certOptions = serverOptions.getCertOptions();
	if (certOptions.getCertType().equalsIgnoreCase("pem")) {
		serverOptions
				.setPemKeyCertOptions(new PemKeyCertOptions().setCertPath(certOptions.getCertPath()).setKeyPath(certOptions.getCertKey()));
	} else if (certOptions.getCertType().equalsIgnoreCase("pfx")) {
		serverOptions.setPfxKeyCertOptions(new PfxOptions().setPath(certOptions.getCertPath()).setPassword(certOptions.getCertKey()));
	} else {
		LOG.error("创建https服务器-->失败:无效的证书类型,只支持pem/pfx格式的证书");
		createHttps.handle(Future.failedFuture("创建https服务器-->失败:无效的证书类型,只支持pem/pfx格式的证书"));
		return;
	}
	Future<Boolean> createFuture = Future.future();
	vertx.fileSystem().exists(certOptions.getCertPath(), createFuture);
	createFuture.setHandler(check -> {
		if (check.succeeded()) {
			if (check.result()) {
				// 404页面
				httpsRouter.route().order(999999).handler(rct -> {
					if (LOG.isDebugEnabled()) {
						LOG.debug(
								"用户: " + rct.request().remoteAddress().host() + "请求的了不存的路径: " + rct.request().method() + ":" + rct.request().path());
					}
					HttpServerResponse response = rct.response();
					if (appOption.getNotFoundContentType() != null) {
						response.putHeader("Content-Type", appOption.getNotFoundContentType());
					}
					response.end(appOption.getNotFoundResult());
				});
				// 如果在linux系统开启epoll
				if (vertx.isNativeTransportEnabled()) {
					serverOptions.setTcpFastOpen(true).setTcpCork(true).setTcpQuickAck(true).setReusePort(true);
				}
				vertx.createHttpServer(serverOptions).requestHandler(httpsRouter::accept).listen(serverOptions.getHttpsPort(), res -> {
					if (res.succeeded()) {
						System.out.println(appOption.getAppName() + " Running on port " + serverOptions.getHttpsPort() + " by HTTPS");
						createHttps.handle(Future.succeededFuture());
					} else {
						System.out.println("create HTTPS Server failed : " + res.cause());
						createHttps.handle(Future.failedFuture(res.cause()));
					}
				});
			} else {
				LOG.error("执行创建https服务器-->失败:无效的证书或者错误的路径:如果证书存放在conf/cert中,路径可以从cert/开始,示例:cert/XXX.XXX");
				createHttps.handle(Future.failedFuture("无效的证书或者错误的路径"));
			}
		} else {
			LOG.error("执行创建https服务器-->失败:无效的证书或者错误的路径:如果证书存放在conf/cert中,路径可以从cert/开始,示例:cert/XXX.XXX", check.cause());
			createHttps.handle(Future.failedFuture(check.cause()));
		}
	});
}
 
Example 19
Source File: DashboardVerticle.java    From microtrader with MIT License 4 votes vote down vote up
@Override
public void start(Future<Void> future) {
    // Get configuration
    config = ConfigFactory.load();

    discovery = ServiceDiscovery.create(vertx, new ServiceDiscoveryOptions().setBackendConfiguration(config()));
    Router router = Router.router(vertx);

    // Event bus bridge
    SockJSHandler sockJSHandler = SockJSHandler.create(vertx);
    BridgeOptions options = new BridgeOptions();
    options
            .addOutboundPermitted(new PermittedOptions().setAddress(config.getString("market.address")))
            .addOutboundPermitted(new PermittedOptions().setAddress(config.getString("portfolio.address")))
            .addOutboundPermitted(new PermittedOptions().setAddress("service.portfolio"))
            .addInboundPermitted(new PermittedOptions().setAddress("service.portfolio"))
            .addOutboundPermitted(new PermittedOptions().setAddress("vertx.circuit-breaker"));

    sockJSHandler.bridge(options);
    router.route("/eventbus/*").handler(sockJSHandler);

    // Discovery endpoint
    ServiceDiscoveryRestEndpoint.create(router, discovery);

    // Last operations
    router.get("/operations").handler(this::callAuditServiceWithExceptionHandlerWithCircuitBreaker);

    // Static content
    router.route("/*").handler(StaticHandler.create());

    // Create a circuit breaker.
    circuit = CircuitBreaker.create("http-audit-service", vertx,
            new CircuitBreakerOptions()
                    .setMaxFailures(2)
                    .setFallbackOnFailure(true)
                    .setResetTimeout(2000)
                    .setTimeout(1000))
                    .openHandler(v -> retrieveAuditService());

    vertx.createHttpServer()
            .requestHandler(router::accept)
            .listen(config.getInt("http.port"), ar -> {
                if (ar.failed()) {
                    future.fail(ar.cause());
                } else {
                    retrieveAuditService();
                    future.complete();
                }
            });
}
 
Example 20
Source File: AwsDeployApplication.java    From vertx-deploy-tools with Apache License 2.0 4 votes vote down vote up
@Override
public void start() {
    MDC.put("service", Constants.SERVICE_ID);
    DeployConfig deployconfig = DeployConfig.fromJsonObject(config());
    if (config() == null) {
        LOG.error("Unable to read config file");
        throw new IllegalStateException("Unable to read config file");
    }
    final DeployApplicationService deployApplicationService = new DeployApplicationService(deployconfig, getVertx());
    final DeployArtifactService deployArtifactService = new DeployArtifactService(getVertx(), deployconfig);
    final DeployConfigService deployConfigService = new DeployConfigService(getVertx(), deployconfig);
    final DefaultDeployService defaultDeployService = new DefaultDeployService(deployApplicationService, deployArtifactService, deployConfigService);

    this.createRunDir(deployconfig);

    deployApplicationService.cleanup().subscribe();
    AwsService awsService = null;
    AutoDiscoverDeployService autoDiscoverDeployService = null;

    if (deployconfig.isAwsEnabled()) {
        awsService = new AwsService(getVertx(), deployconfig);
        autoDiscoverDeployService = new AutoDiscoverDeployService(deployconfig, defaultDeployService, getVertx());
    }

    Router router = Router.router(getVertx());
    router.post("/deploy/deploy").handler(new RestDeployHandler(defaultDeployService, awsService, deployconfig.getAuthToken()));
    router.post("/deploy/module*").handler(new RestDeployModuleHandler(deployApplicationService));
    router.post("/deploy/artifact*").handler(new RestDeployArtifactHandler(deployArtifactService));
    router.get("/deploy/update*").handler(new StatusUpdateHandler(deployApplicationService));

    if (deployconfig.isAwsEnabled()) {
        router.get("/deploy/status/:id").handler(new RestDeployStatusHandler(awsService, deployApplicationService));
    }

    router.get("/status").handler(event -> {
        if (initiated) {
            event.response().setStatusCode(HttpResponseStatus.FORBIDDEN.code());
        } else {
            event.response().setStatusCode(HttpResponseStatus.INTERNAL_SERVER_ERROR.code());
        }
        event.response().end();
        event.response().close();
    });

    HttpServer server = vertx.createHttpServer().requestHandler(router::accept);

    server.listen(deployconfig.getHttpPort());
    initiated = true;
    LOG.info("{}: Instantiated module.", LogConstants.CLUSTER_MANAGER);

    if (deployconfig.isAwsEnabled() && deployconfig.isAwsAutoDiscover() && autoDiscoverDeployService != null) {
        autoDiscoverDeployService.autoDiscoverFirstDeploy();
    }
}