Java Code Examples for io.vertx.ext.web.RoutingContext#addBodyEndHandler()
The following examples show how to use
io.vertx.ext.web.RoutingContext#addBodyEndHandler() .
These examples are extracted from open source projects.
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 Project: vertx-web File: LoggerHandlerImpl.java License: Apache License 2.0 | 6 votes |
@Override public void handle(RoutingContext context) { // common logging data long timestamp = System.currentTimeMillis(); String remoteClient = getClientAddress(context.request().remoteAddress()); HttpMethod method = context.request().method(); String uri = context.request().uri(); HttpVersion version = context.request().version(); if (immediate) { log(context, timestamp, remoteClient, version, method, uri); } else { context.addBodyEndHandler(v -> log(context, timestamp, remoteClient, version, method, uri)); } context.next(); }
Example 2
Source Project: quarkus File: QuarkusJaxRsMetricsFilter.java License: Apache License 2.0 | 5 votes |
@Override public void filter(final ContainerRequestContext requestContext) { Long start = System.nanoTime(); final Class<?> resourceClass = resourceInfo.getResourceClass(); final Method resourceMethod = resourceInfo.getResourceMethod(); /* * The reason for using a Vert.x handler instead of ContainerResponseFilter is that * RESTEasy does not call the response filter for requests that ended up with an unmapped exception. * This way we can capture these responses as well and update the metrics accordingly. */ RoutingContext routingContext = CDI.current().select(CurrentVertxRequest.class).get().getCurrent(); routingContext.addBodyEndHandler( event -> finishRequest(start, resourceClass, resourceMethod)); }
Example 3
Source Project: java-vertx-web File: TracingHandler.java License: Apache License 2.0 | 5 votes |
protected void handlerFailure(RoutingContext routingContext) { Object object = routingContext.get(CURRENT_SPAN); if (object instanceof Span) { final Span span = (Span)object; routingContext.addBodyEndHandler(event -> decorators.forEach(spanDecorator -> spanDecorator.onFailure(routingContext.failure(), routingContext.response(), span))); } routingContext.next(); }
Example 4
Source Project: sfs File: SfsSingletonServer.java License: Apache License 2.0 | 5 votes |
@Override public void handle(RoutingContext routingContext) { routingContext.addBodyEndHandler(event -> { HttpServerRequest request = routingContext.request(); try { request.resume(); } catch (Throwable e) { // do nothing } }); SfsRequest sfsRequest = new SfsRequest(vertxContext, routingContext.request()); delegate.handle(sfsRequest); }
Example 5
Source Project: hono File: TracingHandler.java License: Eclipse Public License 2.0 | 5 votes |
/** * Handles a failed HTTP request. * * @param routingContext The routing context for the request. */ protected void handlerFailure(final RoutingContext routingContext) { final Object object = routingContext.get(CURRENT_SPAN); if (object instanceof Span) { final Span span = (Span) object; routingContext.addBodyEndHandler(event -> decorators.forEach(spanDecorator -> spanDecorator.onFailure(routingContext.failure(), routingContext.response(), span))); } routingContext.next(); }
Example 6
Source Project: mpns File: AccessLogHandler.java License: Apache License 2.0 | 4 votes |
@Override public void handle(RoutingContext context) { long startTime = System.currentTimeMillis(); context.addBodyEndHandler(event -> log(context, startTime)); context.next(); }
Example 7
Source Project: vertx-web File: TimeoutHandlerImpl.java License: Apache License 2.0 | 3 votes |
@Override public void handle(RoutingContext ctx) { // We send a error response after timeout long tid = ctx.vertx().setTimer(timeout, t -> ctx.fail(errorCode)); ctx.addBodyEndHandler(v -> ctx.vertx().cancelTimer(tid)); ctx.next(); }