@Test @DisplayName("Does not serve files outside the local folder") void testServesNoFilesOutsideFolder() { assertThat(get(CONTEXT_URL + "/../" + INDEX_PAGE)) .isNotFound(); }
@GET @Path("{path:.*}") public Response get(@PathParam("path") String path) { java.nio.file.Path resourcePath = contentDirectory.resolve(path); return ifExists(resourcePath) .map(this::getContents) .orElseGet(() -> Response.status(Response.Status.NOT_FOUND)) .build(); }
StaticContentResource { @GET @Path("{path:.*}") public Response get(@PathParam("path") String path) { java.nio.file.Path resourcePath = contentDirectory.resolve(path); return ifExists(resourcePath) .map(this::getContents) .orElseGet(() -> Response.status(Response.Status.NOT_FOUND)) .build(); } }
StaticContentResource { @GET @Path("{path:.*}") public Response get(@PathParam("path") String path) { java.nio.file.Path resourcePath = contentDirectory.resolve(path); return ifExists(resourcePath) .map(this::getContents) .orElseGet(() -> Response.status(Response.Status.NOT_FOUND)) .build(); } protected  StaticContentResource(StaticContent content); protected  StaticContentResource(java.nio.file.Path contentDirectory, String indexPage); }
StaticContentResource { @GET @Path("{path:.*}") public Response get(@PathParam("path") String path) { java.nio.file.Path resourcePath = contentDirectory.resolve(path); return ifExists(resourcePath) .map(this::getContents) .orElseGet(() -> Response.status(Response.Status.NOT_FOUND)) .build(); } protected  StaticContentResource(StaticContent content); protected  StaticContentResource(java.nio.file.Path contentDirectory, String indexPage); @GET Response getInfo(@Context UriInfo uriInfo); @GET @Path("{path:.*}") Response get(@PathParam("path") String path); }
StaticContentResource { @GET @Path("{path:.*}") public Response get(@PathParam("path") String path) { java.nio.file.Path resourcePath = contentDirectory.resolve(path); return ifExists(resourcePath) .map(this::getContents) .orElseGet(() -> Response.status(Response.Status.NOT_FOUND)) .build(); } protected  StaticContentResource(StaticContent content); protected  StaticContentResource(java.nio.file.Path contentDirectory, String indexPage); @GET Response getInfo(@Context UriInfo uriInfo); @GET @Path("{path:.*}") Response get(@PathParam("path") String path);  }