@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 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 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 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 void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, final RestxContext ctx) throws IOException { ctx.nextHandlerMatch().handle(req, resp, ctx.withListener(new AbstractRouteLifecycleListener() { @Override public void onBeforeWriteContent(RestxRequest req, RestxResponse resp) { EntityRelatedFilter.this.onBeforeWriteContent(req, resp, resourceDescription, operationDescription); } @Override public void onAfterWriteContent(RestxRequest req, RestxResponse resp) { EntityRelatedFilter.this.onAfterWriteContent(req, resp, resourceDescription, operationDescription); } @Override public void onEntityInput(RestxRoute route, RestxRequest req, RestxResponse resp, Optional<?> input) { EntityRelatedFilter.this.onEntityInput(stdRoute, req, resp, input, resourceDescription, operationDescription); } @Override public void onEntityOutput(RestxRoute route, RestxRequest req, RestxResponse resp, Optional<?> input, Optional<?> output) { EntityRelatedFilter.this.onEntityOutput(stdRoute, req, resp, input, output, resourceDescription, operationDescription); } })); } }));
@Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, final RestxContext ctx) throws IOException { ctx.nextHandlerMatch().handle(req, resp, ctx.withListener(new AbstractRouteLifecycleListener() { @Override public void onBeforeWriteContent(RestxRequest req, RestxResponse resp) { EntityRelatedFilter.this.onBeforeWriteContent(req, resp, resourceDescription, operationDescription); } @Override public void onAfterWriteContent(RestxRequest req, RestxResponse resp) { EntityRelatedFilter.this.onAfterWriteContent(req, resp, resourceDescription, operationDescription); } @Override public void onEntityInput(RestxRoute route, RestxRequest req, RestxResponse resp, Optional<?> input) { EntityRelatedFilter.this.onEntityInput(stdRoute, req, resp, input, resourceDescription, operationDescription); } @Override public void onEntityOutput(RestxRoute route, RestxRequest req, RestxResponse resp, Optional<?> input, Optional<?> output) { EntityRelatedFilter.this.onEntityOutput(stdRoute, req, resp, input, output, resourceDescription, operationDescription); } })); } }));
@Override public void handle(RestxRequestMatch match, RestxRequest req, final RestxResponse resp, RestxContext ctx) throws IOException { final RestxSession session = buildContextFromRequest(req); if (RestxContext.Modes.RECORDING.equals(ctx.getMode())) { // we invalidate caches in recording mode so that each request records the cache loading // Note: having this piece of code here is not a very nice isolation of responsibilities // we could put it in a separate filter, but then it's not easy to be sure it's called right after this // filter. Until such a feature is introduced, the easy solution to put it here is used. sessionDefinition.invalidateAllCaches(); } RestxSession.setCurrent(session); try { RouteLifecycleListener lifecycleListener = new AbstractRouteLifecycleListener() { @Override public void onBeforeWriteContent(RestxRequest req, RestxResponse resp) { RestxSession newSession = RestxSession.current(); if (newSession != session) { updateSessionInClient(resp, newSession); } } }; ctx.nextHandlerMatch().handle(req, resp, ctx.withListener(lifecycleListener)); } finally { RestxSession.setCurrent(null); // we don't remove the MDC principal here, we want to keep it until the end of the request } }
@Override public void handle(RestxRequestMatch match, RestxRequest req, final RestxResponse resp, RestxContext ctx) throws IOException { final RestxSession session = buildContextFromRequest(req); if (RestxContext.Modes.RECORDING.equals(ctx.getMode())) { // we invalidate caches in recording mode so that each request records the cache loading // Note: having this piece of code here is not a very nice isolation of responsibilities // we could put it in a separate filter, but then it's not easy to be sure it's called right after this // filter. Until such a feature is introduced, the easy solution to put it here is used. sessionDefinition.invalidateAllCaches(); } RestxSession.setCurrent(session); try { RouteLifecycleListener lifecycleListener = new AbstractRouteLifecycleListener() { @Override public void onBeforeWriteContent(RestxRequest req, RestxResponse resp) { RestxSession newSession = RestxSession.current(); if (newSession != session) { updateSessionInClient(resp, newSession); } } }; ctx.nextHandlerMatch().handle(req, resp, ctx.withListener(lifecycleListener)); } finally { RestxSession.setCurrent(null); // we don't remove the MDC principal here, we want to keep it until the end of the request } }