public static Optional<RestxHandlerMatch> of(Optional<? extends RestxRequestMatch> match, Supplier<? extends RestxHandler> handler) { return match.isPresent() ? Optional.of(new RestxHandlerMatch(match.get(), handler.get())) : Optional.<RestxHandlerMatch>absent(); }
@Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException { ctx.nextHandlerMatch().handle(req, resp, ctx); try { resp.close(); } catch (Exception e) { logger.error("ERROR while closing response: " + e.getMessage(), e); } } }
public static Optional<RestxHandlerMatch> of(Optional<? extends RestxRequestMatch> match, RestxHandler handler) { return of(match, Suppliers.ofInstance(handler)); }
public static Optional<RestxHandlerMatch> of(Optional<? extends RestxRequestMatch> match, Supplier<? extends RestxHandler> handler) { return match.isPresent() ? Optional.of(new RestxHandlerMatch(match.get(), handler.get())) : Optional.<RestxHandlerMatch>absent(); }
@Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException { ctx.nextHandlerMatch().handle(req, resp, ctx); try { resp.close(); } catch (Exception e) { logger.error("ERROR while closing response: " + e.getMessage(), e); } } }
public static Optional<RestxHandlerMatch> of(Optional<? extends RestxRequestMatch> match, RestxHandler handler) { return of(match, Suppliers.ofInstance(handler)); }
@Override public Optional<RestxHandlerMatch> match(RestxRoute route) { return Optional.of(new RestxHandlerMatch(new StdRestxRequestMatch("/*"), this)); }
@Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException { Stopwatch stopwatch = Stopwatch.createStarted(); try { ctx.nextHandlerMatch().handle(req, resp, ctx); } finally { collector.notifyRequest(req, resp, stopwatch.stop()); } }
@Override public Optional<RestxHandlerMatch> match(RestxRequest req) { String path = req.getRestxPath(); return RestxHandlerMatch.of(matcher.match(req.getHttpMethod(), path), this); }
@Override public Optional<RestxHandlerMatch> match(RestxRoute route) { return Optional.of(new RestxHandlerMatch(new StdRestxRequestMatch("/*"), this)); }
@Override public void handle(RestxRequestMatch restxRequestMatch, RestxRequest restxRequest, RestxResponse restxResponse, RestxContext restxContext) throws IOException { try { restxContext.nextHandlerMatch().handle(restxRequest, new RestxResponseWrapper(restxResponse) { private GZIPOutputStream gzipOutputStream; @Override public OutputStream getOutputStream() throws IOException { setHeader("Content-Encoding", "gzip"); return gzipOutputStream = new GZIPOutputStream(super.getOutputStream()); } @Override public void close() throws Exception { if (gzipOutputStream != null) { try { gzipOutputStream.close(); } finally { gzipOutputStream = null; } } super.close(); } }, restxContext); } finally { } } }
@Override public Optional<RestxHandlerMatch> match(RestxRequest req) { String path = req.getRestxPath(); return RestxHandlerMatch.of(matcher.match(req.getHttpMethod(), path), this); }
@Override public Optional<RestxHandlerMatch> match(RestxRoute route) { return Optional.of(new RestxHandlerMatch(new StdRestxRequestMatch("/*"), this)); }
@Override public void handle(RestxRequestMatch restxRequestMatch, RestxRequest restxRequest, RestxResponse restxResponse, RestxContext restxContext) throws IOException { try { restxContext.nextHandlerMatch().handle(restxRequest, new RestxResponseWrapper(restxResponse) { private GZIPOutputStream gzipOutputStream; @Override public OutputStream getOutputStream() throws IOException { setHeader("Content-Encoding", "gzip"); return gzipOutputStream = new GZIPOutputStream(super.getOutputStream()); } @Override public void close() throws Exception { if (gzipOutputStream != null) { try { gzipOutputStream.close(); } finally { gzipOutputStream = null; } } super.close(); } }, restxContext); } finally { } } }
@Override public Optional<RestxHandlerMatch> match(RestxRoute route) { return Optional.of(new RestxHandlerMatch(new StdRestxRequestMatch("/*"), this)); }
@Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException { ctx.nextHandlerMatch().handle(req, resp, ctx.withListener(new AbstractRouteLifecycleListener() { @Override @SuppressWarnings("unchecked") public void onEntityOutput(RestxRoute route, RestxRequest req, RestxResponse resp, Optional<?> input, Optional<?> output) { if (output.isPresent()) { provider.provideETagFor((T) output.get()).handleIn(req, resp); } } })); } }
@Override public Optional<RestxHandlerMatch> match(RestxRoute route) { return Optional.of(new RestxHandlerMatch(new StdRestxRequestMatch("/*"), this)); }
@Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException { ctx.nextHandlerMatch().handle(req, resp, ctx.withListener(new AbstractRouteLifecycleListener() { @Override public void onBeforeWriteContent(RestxRequest req, RestxResponse resp) { if (!resp.getHeader("Cache-Control").isPresent()) { resp.setHeader("Cache-Control", "no-cache"); } } })); } }));
@Override public Optional<RestxHandlerMatch> match(RestxRoute route) { return Optional.of(new RestxHandlerMatch(new StdRestxRequestMatch("/*"), this)); }
@Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException { ctx.nextHandlerMatch().handle(req, resp, ctx.withListener(new AbstractRouteLifecycleListener() { @Override @SuppressWarnings("unchecked") public void onEntityOutput(RestxRoute route, RestxRequest req, RestxResponse resp, Optional<?> input, Optional<?> output) { if (output.isPresent()) { provider.provideETagFor((T) output.get()).handleIn(req, resp); } } })); } }