router.route().handler(StaticHandler.create().setCachingEnabled(false));
router.route("/private/*").handler(StaticHandler.create().setCachingEnabled(false).setWebRoot("private"));
router.route("/private/*").handler(StaticHandler.create().setCachingEnabled(false).setWebRoot("private"));
/** * Set whether cache header handling is enabled * @param enabled true if enabled * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.StaticHandler setCachingEnabled(boolean enabled) { delegate.setCachingEnabled(enabled); return this; }
/** * Set whether cache header handling is enabled * @param enabled true if enabled * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.StaticHandler setCachingEnabled(boolean enabled) { delegate.setCachingEnabled(enabled); return this; }
@Test public void testCachingDisabled() throws Exception { stat.setCachingEnabled(false); testRequest(HttpMethod.GET, "/otherpage.html", null, res -> { String cacheControl = res.headers().get("cache-control"); String lastModified = res.headers().get("last-modified"); assertNull(cacheControl); assertNull(lastModified); }, 200, "OK", "<html><body>Other page</body></html>"); }
@Test public void testFSBlockingTuning() throws Exception { stat.setCachingEnabled(false); stat.setMaxAvgServeTimeNs(10000); for (int i = 0; i < 2000; i++) { testRequest(HttpMethod.GET, "/otherpage.html", null, res -> { String cacheControl = res.headers().get("cache-control"); String lastModified = res.headers().get("last-modified"); assertNull(cacheControl); assertNull(lastModified); }, 200, "OK", "<html><body>Other page</body></html>"); } }
public void addStaticHandler() { StaticHandler staticHandler = StaticHandler.create("elastichead"); staticHandler.setDirectoryListing(false); staticHandler.setCachingEnabled(false); staticHandler.setIndexPage("index.html"); route("/*").method(GET).handler(staticHandler); }
@Test public void testCachingDisabled() throws Exception { stat.setCachingEnabled(false); testRequest(HttpMethod.GET, "/otherpage.html", null, res -> { String cacheControl = res.headers().get("cache-control"); String lastModified = res.headers().get("last-modified"); assertNull(cacheControl); assertNull(lastModified); }, 200, "OK", "<html><body>Other page</body></html>"); }
@Test public void testFSBlockingTuning() throws Exception { stat.setCachingEnabled(false); stat.setMaxAvgServeTimeNs(10000); for (int i = 0; i < 2000; i++) { testRequest(HttpMethod.GET, "/otherpage.html", null, res -> { String cacheControl = res.headers().get("cache-control"); String lastModified = res.headers().get("last-modified"); assertNull(cacheControl); assertNull(lastModified); }, 200, "OK", "<html><body>Other page</body></html>"); } }
@Override public void registerEndPoints() { secureAll(); InternalEndpointRoute queryEndpoint = createRoute(); queryEndpoint.method(POST); queryEndpoint.exampleRequest(graphqlExamples.createQueryRequest()); queryEndpoint.exampleResponse(OK, graphqlExamples.createResponse(), "Basic GraphQL response."); queryEndpoint.description("Endpoint which accepts GraphQL queries."); queryEndpoint.path("/"); queryEndpoint.blockingHandler(rc -> { GraphQLContext gc = new GraphQLContextImpl(rc); String body = gc.getBodyAsString(); queryHandler.handleQuery(gc, body); }, false); StaticHandler staticHandler = StaticHandler.create("graphiql"); staticHandler.setDirectoryListing(false); staticHandler.setCachingEnabled(false); staticHandler.setIndexPage("index.html"); // Redirect handler route("/browser").method(GET).handler(rc -> { if (rc.request().path().endsWith("/browser")) { rc.response().setStatusCode(302); rc.response().headers().set("Location", rc.request().path() + "/"); rc.response().end(); } else { rc.next(); } }); route("/browser/*").method(GET).handler(staticHandler); }