io.vertx.ext.web.handler.BodyHandler Java Examples
The following examples show how to use
io.vertx.ext.web.handler.BodyHandler.
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: MainVerticle.java From okapi with Apache License 2.0 | 7 votes |
@Override public void start(Promise<Void> promise) throws IOException { Router router = Router.router(vertx); Auth auth = new Auth(); final int port = Integer.parseInt(System.getProperty("port", "9020")); logger.info("Starting auth {} on port {}", ManagementFactory.getRuntimeMXBean().getName(), port); router.post("/authn/login").handler(BodyHandler.create()); router.post("/authn/login").handler(auth::login); router.route("/authn/login").handler(auth::accept); router.route("/*").handler(auth::filter); vertx.createHttpServer() .requestHandler(router) .listen(port, result -> promise.handle(result.mapEmpty())); }
Example #2
Source File: HttpServiceBase.java From hono with Eclipse Public License 2.0 | 6 votes |
/** * Creates the router for handling requests. * <p> * This method creates a router instance along with a route matching all request. That route is initialized with the * following handlers and failure handlers: * <ul> * <li>a handler and failure handler that creates tracing data for all server requests,</li> * <li>a default failure handler,</li> * <li>a handler limiting the body size of requests to the maximum payload size set in the <em>config</em> * properties.</li> * </ul> * * @return The newly created router (never {@code null}). */ protected Router createRouter() { final Router router = Router.router(vertx); final Route matchAllRoute = router.route(); // the handlers and failure handlers are added here in a specific order! // 1. tracing handler final TracingHandler tracingHandler = createTracingHandler(); matchAllRoute.handler(tracingHandler).failureHandler(tracingHandler); // 2. default handler for failed routes matchAllRoute.failureHandler(new DefaultFailureHandler()); // 3. BodyHandler with request size limit log.info("limiting size of inbound request body to {} bytes", getConfig().getMaxPayloadSize()); matchAllRoute.handler(BodyHandler.create().setUploadsDirectory(DEFAULT_UPLOADS_DIRECTORY) .setBodyLimit(getConfig().getMaxPayloadSize())); //4. AuthHandler addAuthHandler(router); return router; }
Example #3
Source File: RouterFactoryIntegrationTest.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Tests that user can supply customised BodyHandler * * @throws Exception */ @Test public void customBodyHandlerTest(Vertx vertx, VertxTestContext testContext) { RouterFactory.create(vertx, "src/test/resources/specs/upload_test.yaml", testContext.succeeding(routerFactory -> { routerFactory.setOptions(new RouterFactoryOptions().setRequireSecurityHandlers(false)); BodyHandler bodyHandler = BodyHandler.create("my-uploads"); routerFactory.bodyHandler(bodyHandler); routerFactory.operation("upload").handler(routingContext -> routingContext.response().setStatusCode(201).end()); testContext.verify(() -> { assertThat(routerFactory.createRouter().getRoutes().get(0)) .extracting("state") .extracting("contextHandlers") .asList() .hasOnlyOneElementSatisfying(b -> assertThat(b).isSameAs(bodyHandler)); }); testContext.completeNow(); })); }
Example #4
Source File: RestStoreAPIVerticle.java From vertx-blueprint-microservice with Apache License 2.0 | 6 votes |
@Override public void start(Future<Void> future) throws Exception { super.start(); Router router = Router.router(vertx); // body handler router.route().handler(BodyHandler.create()); // API route handler router.post(API_SAVE).handler(this::apiSave); router.get(API_RETRIEVE).handler(this::apiRetrieve); router.delete(API_CLOSE).handler(this::apiClose); // get HTTP host and port from configuration, or use default value String host = config().getString("store.http.address", "0.0.0.0"); int port = config().getInteger("store.http.port", 8085); createHttpServer(router, host, port) .compose(serverCreated -> publishHttpEndpoint(SERVICE_NAME, host, port)) .setHandler(future.completer()); }
Example #5
Source File: HttpVerticle.java From reactive-refarch-cloudformation with Apache License 2.0 | 6 votes |
@Override public void start() { this.eb = vertx.eventBus(); Router router = Router.router(vertx); router.route().handler(BodyHandler.create()); router.get("/event/:eventID").handler(this::handleTrackingEvent); router.get("/cache/fill").handler(this::fillCacheWithData); router.get("/cache/purge").handler(this::purgeCache); router.get("/health/check").handler(this::checkHealth); HttpServerOptions httpServerOptions = new HttpServerOptions(); httpServerOptions.setCompressionSupported(true); HttpServer httpServer = vertx.createHttpServer(httpServerOptions); httpServer.requestHandler(router).listen(8080); }
Example #6
Source File: HTTPRequestValidationTest.java From vertx-web with Apache License 2.0 | 6 votes |
@Test public void testFormMultipartParamWithIncludedTypes() throws Exception { HTTPRequestValidationHandler validationHandler = HTTPRequestValidationHandler.create().addFormParam("parameter", ParameterType.INT, true); router.route().handler(BodyHandler.create(tempFolder.getRoot().getAbsolutePath())); router.post("/testFormParam").handler(validationHandler); router.post("/testFormParam").handler(routingContext -> { RequestParameters params = routingContext.get("parsedParameters"); routingContext.response().setStatusMessage(params.formParameter("parameter").getInteger().toString()).end(); }).failureHandler(generateFailureHandler(false)); String formParam = getSuccessSample(ParameterType.INT).getInteger().toString(); MultiMap form = MultiMap.caseInsensitiveMultiMap(); form.add("parameter", formParam); testRequestWithForm(HttpMethod.POST, "/testFormParam", FormType.MULTIPART, form, 200, formParam); }
Example #7
Source File: RestRouterTest.java From rest.vertx with Apache License 2.0 | 6 votes |
@BeforeAll static void start() { before(); TestRest testRest = new TestRest(); BodyHandler bodyHandler = BodyHandler.create("my_upload_folder"); RestRouter.setBodyHandler(bodyHandler); Router router = RestRouter.register(vertx, testRest, TestRestWithNonRestMethod.class); vertx.createHttpServer() .requestHandler(router) .listen(PORT, vertxTestContext.succeeding()); }
Example #8
Source File: RestBuilderTest.java From rest.vertx with Apache License 2.0 | 6 votes |
@Test void buildInterfaceTest() { BodyHandler handler = BodyHandler.create("my_upload_folder"); new RestBuilder(vertx) .bodyHandler(handler) .register(TestRest.class, TestRegExRest.class, TestPostRest.class) .reader(Dummy.class, DummyBodyReader.class) .writer(MediaType.APPLICATION_JSON, TestCustomWriter.class) .errorHandler(IllegalArgumentExceptionHandler.class) .errorHandler(MyExceptionHandler.class) .provide(request -> new Dummy("test", "name")) .addProvider(TokenProvider.class) .build(); }
Example #9
Source File: RouteToEBServiceHandlerTest.java From vertx-web with Apache License 2.0 | 6 votes |
@Test public void binaryDataTest(Vertx vertx, VertxTestContext testContext) { Checkpoint checkpoint = testContext.checkpoint(); BinaryTestService service = new BinaryTestServiceImpl(); final ServiceBinder serviceBinder = new ServiceBinder(vertx).setAddress("someAddress"); consumer = serviceBinder .setIncludeDebugInfo(true) .register(BinaryTestService.class, service); router .get("/test") .handler(BodyHandler.create()) .handler( ValidationHandler.builder(parser).build() ).handler( RouteToEBServiceHandler.build(vertx.eventBus(), "someAddress", "binaryTest") ); testRequest(client, HttpMethod.GET, "/test") .expect(statusCode(200), statusMessage("OK")) .expect(bodyResponse(Buffer.buffer(new byte[] {(byte) 0xb0}), "application/octet-stream")) .send(testContext, checkpoint); }
Example #10
Source File: RestProductAPIVerticle.java From vertx-blueprint-microservice with Apache License 2.0 | 6 votes |
@Override public void start(Future<Void> future) throws Exception { super.start(); final Router router = Router.router(vertx); // body handler router.route().handler(BodyHandler.create()); // API route handler router.post(API_ADD).handler(this::apiAdd); router.get(API_RETRIEVE_BY_PAGE).handler(this::apiRetrieveByPage); router.get(API_RETRIEVE_ALL).handler(this::apiRetrieveAll); router.get(API_RETRIEVE_PRICE).handler(this::apiRetrievePrice); router.get(API_RETRIEVE).handler(this::apiRetrieve); router.patch(API_UPDATE).handler(this::apiUpdate); router.delete(API_DELETE).handler(this::apiDelete); router.delete(API_DELETE_ALL).handler(context -> requireLogin(context, this::apiDeleteAll)); // get HTTP host and port from configuration, or use default value String host = config().getString("product.http.address", "0.0.0.0"); int port = config().getInteger("product.http.port", 8082); // create HTTP server and publish REST service createHttpServer(router, host, port) .compose(serverCreated -> publishHttpEndpoint(SERVICE_NAME, host, port)) .setHandler(future.completer()); }
Example #11
Source File: CURLClientVerticle.java From VX-API-Gateway with MIT License | 6 votes |
@Override public void start(Future<Void> fut) throws Exception { thisVertxName = System.getProperty("thisVertxName", "VX-API"); Router router = Router.router(vertx); router.route().handler(BodyHandler.create()); router.route().handler(ResponseContentTypeHandler.create()); // 通过curl的方式创建网关应用 router.route("/curl/findAPP").produces(CONTENT_VALUE_JSON_UTF8).handler(this::findAPPbyCURL); vertx.createHttpServer().requestHandler(router::accept).listen(5053, res -> { if (res.succeeded()) { System.out.println("The VX-API console running on port 5053"); fut.complete(); } else { fut.fail(res.cause()); } }); }
Example #12
Source File: ApiVerticle.java From gushici with GNU General Public License v3.0 | 6 votes |
@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 #13
Source File: RestOrderAPIVerticle.java From vertx-blueprint-microservice with Apache License 2.0 | 6 votes |
@Override public void start(Future<Void> future) throws Exception { super.start(); Router router = Router.router(vertx); // body handler router.route().handler(BodyHandler.create()); // API route router.get(API_RETRIEVE).handler(this::apiRetrieve); router.get(API_RETRIEVE_FOR_ACCOUNT).handler(context -> requireLogin(context, this::apiRetrieveForAccount)); String host = config().getString("order.http.address", "0.0.0.0"); int port = config().getInteger("order.http.port", 8090); // create HTTP server and publish REST service createHttpServer(router, host, port) .compose(serverCreated -> publishHttpEndpoint(SERVICE_NAME, host, port)) .setHandler(future.completer()); }
Example #14
Source File: GaeHttpServer.java From gae with MIT License | 6 votes |
@Override public void start() { HttpServer server = vertx.createHttpServer(); Router router = Router.router(vertx); router.route().handler(BodyHandler.create()); router.route().handler(ResponseTimeHandler.create()); router.route("/") .handler(jsonHandlerVertx) .handler(authHandlerVertx) // .blockingHandler(bidHandlerVertx, false) .handler(bidHandlerVertx) .failureHandler(errorHandlerVertx); server.requestHandler(router::accept).listen(serverProps.getPort()); }
Example #15
Source File: ApiController.java From exonum-java-binding with Apache License 2.0 | 6 votes |
void mountApi(Router router) { // Mount the body handler to process bodies of some POST queries, and the handler of failures. router.route() .handler(BodyHandler.create()) .failureHandler(this::failureHandler); // Mount the handlers of each request ImmutableMap<String, Handler<RoutingContext>> handlers = ImmutableMap.<String, Handler<RoutingContext>>builder() .put(SUBMIT_INCREMENT_COUNTER_TX_PATH, this::submitIncrementCounter) .put(SUBMIT_UNKNOWN_TX_PATH, this::submitUnknownTx) .put(GET_COUNTER_PATH, this::getCounter) .put(GET_CONSENSUS_CONFIGURATION_PATH, this::getConsensusConfiguration) .put(TIME_PATH, this::getTime) .put(VALIDATORS_TIMES_PATH, this::getValidatorsTimes) .build(); handlers.forEach((path, handler) -> router.route(path).handler(handler) ); }
Example #16
Source File: RecommendationPersistenceVerticle.java From istio-tutorial with Apache License 2.0 | 6 votes |
@Override public void start() throws Exception { Router router = Router.router(vertx); router.get("/").handler(this::logging); router.route().handler(BodyHandler.create()); initJdbc(vertx); router.get("/").handler(this::getRecommendationsFromDb); router.post("/").handler(this::addRecommendation); // router.post("/").handler(this::addRecommendationToBothColumns); // router.post("/").handler(this::addRecommendationToNewColumn); HealthCheckHandler hc = HealthCheckHandler.create(vertx); hc.register("dummy-health-check", future -> future.complete(Status.OK())); router.get("/health/ready").handler(hc); router.get("/health/live").handler(hc); vertx.createHttpServer().requestHandler(router::accept).listen(LISTEN_ON); }
Example #17
Source File: SockJSCORSTest.java From vertx-web with Apache License 2.0 | 6 votes |
@Test public void testNoConflictsSockJSAndCORSHandler() { router .route() .handler(CorsHandler.create("*").allowCredentials(false)) .handler(BodyHandler.create()); SockJSProtocolTest.installTestApplications(router, vertx); client.get("/echo/info?t=21321", HttpHeaders.set(HttpHeaders.ORIGIN, "example.com"), onSuccess(resp -> { assertEquals(200, resp.statusCode()); assertEquals("*", resp.getHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN)); assertFalse(resp.headers().contains(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS)); //If the SockJS handles the CORS stuff, it would reply with allow credentials true and allow origin example.com complete(); })); await(); }
Example #18
Source File: PipelineRouteDefiner.java From konduit-serving with Apache License 2.0 | 6 votes |
static void generalHandler(InferenceConfiguration inferenceConfiguration, Router router, Logger log) { router.post().handler(BodyHandler.create() .setUploadsDirectory(inferenceConfiguration.getServingConfig().getUploadsDirectory()) .setDeleteUploadedFilesOnEnd(true) .setMergeFormAttributes(true)) .failureHandler(failureHandlder -> { if (failureHandlder.statusCode() == 404) { log.warn("404 at route {}", failureHandlder.request().path()); } else if (failureHandlder.failed()) { if (failureHandlder.failure() != null) { log.error("Request failed with cause ", failureHandlder.failure()); } else { log.error("Request failed with unknown cause."); } } failureHandlder.response() .setStatusCode(500) .end(failureHandlder.failure().toString()); }); }
Example #19
Source File: ServiceDiscoveryRestEndpoint.java From vertx-service-discovery with Apache License 2.0 | 6 votes |
/** * Registers the routes. * * @param router the router * @param root the root */ private void registerRoutes(Router router, String root) { // Get all and query router.get(root).handler(this::all); // Get one router.get(root + "/:uuid").handler(this::one); // Unpublish router.delete(root + "/:uuid").handler(this::unpublish); // Publish router.route().handler(BodyHandler.create()); router.post(root).handler(this::publish); // Update router.put(root + "/:uuid").handler(this::update); }
Example #20
Source File: RestShoppingAPIVerticle.java From vertx-blueprint-microservice with Apache License 2.0 | 6 votes |
@Override public void start(Future<Void> future) throws Exception { super.start(); final Router router = Router.router(vertx); // body handler router.route().handler(BodyHandler.create()); // api route handler router.post(API_CHECKOUT).handler(context -> requireLogin(context, this::apiCheckout)); router.post(API_ADD_CART_EVENT).handler(context -> requireLogin(context, this::apiAddCartEvent)); router.get(API_GET_CART).handler(context -> requireLogin(context, this::apiGetCart)); enableLocalSession(router); // get HTTP host and port from configuration, or use default value String host = config().getString("shopping.cart.http.address", "0.0.0.0"); int port = config().getInteger("shopping.cart.http.port", 8084); // create http server for the REST service createHttpServer(router, host, port) .compose(serverCreated -> publishHttpEndpoint(SERVICE_NAME, host, port)) .setHandler(future.completer()); }
Example #21
Source File: DelegatingCredentialsManagementHttpEndpoint.java From hono with Eclipse Public License 2.0 | 6 votes |
@Override public void addRoutes(final Router router) { final String pathWithTenantAndDeviceId = String.format("/%s/:%s/:%s", getName(), PARAM_TENANT_ID, PARAM_DEVICE_ID); // Add CORS handler router.route(pathWithTenantAndDeviceId).handler(createCorsHandler(config.getCorsAllowedOrigin(), EnumSet.of(HttpMethod.GET, HttpMethod.PUT))); final BodyHandler bodyHandler = BodyHandler.create(); bodyHandler.setBodyLimit(config.getMaxPayloadSize()); // get all credentials for a given device router.get(pathWithTenantAndDeviceId).handler(this::getCredentialsForDevice); // set credentials for a given device router.put(pathWithTenantAndDeviceId).handler(bodyHandler); router.put(pathWithTenantAndDeviceId).handler(this::extractRequiredJsonArrayPayload); router.put(pathWithTenantAndDeviceId).handler(this::extractIfMatchVersionParam); router.put(pathWithTenantAndDeviceId).handler(this::updateCredentials); }
Example #22
Source File: WebSocketService.java From besu with Apache License 2.0 | 6 votes |
private Handler<HttpServerRequest> httpHandler() { final Router router = Router.router(vertx); // Verify Host header to avoid rebind attack. router.route().handler(checkAllowlistHostHeader()); if (authenticationService.isPresent()) { router.route("/login").handler(BodyHandler.create()); router .post("/login") .produces(APPLICATION_JSON) .handler(authenticationService.get()::handleLogin); } else { router .post("/login") .produces(APPLICATION_JSON) .handler(AuthenticationService::handleDisabledLogin); } router.route().handler(WebSocketService::handleHttpNotSupported); return router; }
Example #23
Source File: CurrencyService.java From vertx-kubernetes-workshop with Apache License 2.0 | 5 votes |
@Override public void start(Future<Void> future) throws Exception { Router router = Router.router(vertx); router.get().handler(rc -> rc.response().end("OK")); router.post().handler(BodyHandler.create()); router.post().handler(this::handle); vertx.createHttpServer() .requestHandler(router::accept) .listen(config().getInteger("port", 8080), ar -> future.handle(ar.mapEmpty())); }
Example #24
Source File: InventoryRestAPIVerticle.java From vertx-blueprint-microservice with Apache License 2.0 | 5 votes |
@Override public void start(Future<Void> future) throws Exception { super.start(); configurationRetriever // TODO: enhance its usage .usingScanPeriod(SCAN_PERIOD) .withHttpStore("config-server", 80, "/inventory-microservice/docker.json") .rxCreateConfig(vertx) .subscribe(log4jSubscriber); this.inventoryService = InventoryService.createService(vertx, config()); final Router router = Router.router(vertx); // body handler router.route().handler(BodyHandler.create()); // API handler router.get(API_RETRIEVE).handler(this::apiRetrieve); router.put(API_INCREASE).handler(this::apiIncrease); router.put(API_DECREASE).handler(this::apiDecrease); // get HTTP host and port from configuration, or use default value String host = config().getString("inventory.http.address", "0.0.0.0"); int port = config().getInteger("inventory.http.port", 8086); createHttpServer(router, host, port) .compose(serverCreated -> publishHttpEndpoint(SERVICE_NAME, host, port)) .setHandler(future.completer()); }
Example #25
Source File: RestRouter.java From rest.vertx with Apache License 2.0 | 5 votes |
public static void setBodyHandler(BodyHandler handler) { if (bodyHandler != null) { log.error("Body handler already defined, set body handler before any routes!"); return; } Assert.notNull(handler, "Missing body handler!"); bodyHandler = handler; }
Example #26
Source File: HTTPRequestValidationTest.java From vertx-web with Apache License 2.0 | 5 votes |
@Test public void testValidationHandlerChaining() throws Exception { HTTPRequestValidationHandler validationHandler1 = HTTPRequestValidationHandler .create() .addQueryParam("param1", ParameterType.INT, true); HTTPRequestValidationHandler validationHandler2 = HTTPRequestValidationHandler .create() .addQueryParam("param2", ParameterType.BOOL, true); router.route().handler(BodyHandler.create()); router.get("/testHandlersChaining") .handler(validationHandler1) .handler(validationHandler2) .handler(routingContext -> { RequestParameters params = routingContext.get("parsedParameters"); assertNotNull(params.queryParameter("param1")); assertNotNull(params.queryParameter("param2")); routingContext .response() .setStatusMessage( params.queryParameter("param1").getInteger().toString() + params.queryParameter("param2").getBoolean() ).end(); }).failureHandler(generateFailureHandler(false)); String param1 = getSuccessSample(ParameterType.INT).getInteger().toString(); String param2 = getSuccessSample(ParameterType.BOOL).getBoolean().toString(); testRequest(HttpMethod.GET, "/testHandlersChaining?param1=10¶m2=true", 200, "10true"); }
Example #27
Source File: ValidationHandlerProcessorsIntegrationTest.java From vertx-web with Apache License 2.0 | 5 votes |
@Test public void testJsonBody(VertxTestContext testContext, @TempDir Path tempDir) { Checkpoint checkpoint = testContext.checkpoint(2); ValidationHandler validationHandler = ValidationHandler .builder(parser) .body(Bodies.json(objectSchema())) .build(); router.post("/test") .handler(BodyHandler.create(tempDir.toAbsolutePath().toString())) .handler(validationHandler) .handler(routingContext -> { RequestParameters params = routingContext.get("parsedParameters"); routingContext .response() .setStatusMessage( params.body().getJsonObject().toString() ) .end(); }); testRequest(client, HttpMethod.POST, "/test") .expect(statusCode(200), statusMessage("{}")) .sendJson(new JsonObject(), testContext, checkpoint); testRequest(client, HttpMethod.POST, "/test") .expect(statusCode(400)) .expect(badBodyResponse(BodyProcessorException.BodyProcessorErrorType.VALIDATION_ERROR)) .sendJson("aaa", testContext, checkpoint); }
Example #28
Source File: AbstractVertxHttpDispatcher.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
protected BodyHandler createBodyHandler() { RestBodyHandler bodyHandler = new RestBodyHandler(); UploadConfig uploadConfig = new UploadConfig(); bodyHandler.setUploadsDirectory(uploadConfig.getLocation()); bodyHandler.setDeleteUploadedFilesOnEnd(true); bodyHandler.setBodyLimit(uploadConfig.getMaxSize()); if (uploadConfig.toMultipartConfigElement() != null) { LOGGER.info("set uploads directory to \"{}\".", uploadConfig.getLocation()); } return bodyHandler; }
Example #29
Source File: BatchInputArrowParserVerticle.java From konduit-serving with Apache License 2.0 | 5 votes |
@Override public void init(Vertx vertx, Context context) { super.init(vertx, context); router = Router.router(vertx); if (config().containsKey(INPUT_NAME_KEY)) { inputName = config().getString(INPUT_NAME_KEY); } BatchInputParser batchInputParser = BatchInputParser.builder() .inputParts(Collections.singletonList(inputName)) .converters(Collections.singletonMap(inputName, new ArrowBinaryInputAdapter())) .converterArgs(Collections.singletonMap(inputName, ConverterArgs.builder() .strings(Collections.singletonList(DataType.INT64.name())).build())).build(); BatchInputArrowParserVerticle.this.inputParser = batchInputParser; router().post().handler(BodyHandler.create() .setUploadsDirectory(System.getProperty("java.io.tmpdir")) .setMergeFormAttributes(true)) .failureHandler(failureHandler -> { log.error("Request failed due to: ", failureHandler.failure()); failureHandler.response() .setStatusCode(failureHandler.statusCode()) .end(failureHandler.failure().getMessage()); }); router.post("/").handler(itemHandler -> { try { BatchInputArrowParserVerticle.this.batch = batchInputParser.createBatch(itemHandler); } catch (IOException e) { log.error("Error while parsing arrow batch", e); } itemHandler.response().end(); }); }
Example #30
Source File: SockJSAsyncHandlerTest.java From vertx-web with Apache License 2.0 | 5 votes |
@Override public void setUp() throws Exception { // Use two servers so we test with HTTP request/response with load balanced SockJSSession access numServers = 2; preSockJSHandlerSetup = router -> { router.route().handler(BodyHandler.create()); // simulate an async handler router.route().handler(rtx -> rtx.vertx().executeBlocking(f -> f.complete(true), r -> rtx.next())); }; super.setUp(); }