Skip to content

Instantly share code, notes, and snippets.

View ralfbecher's full-sized avatar

Ralf Becher ralfbecher

View GitHub Profile
ʕ◔ϖ◔ʔ
U+0295, U+25D4, U+03D6, U+25D4, U+0294
@jexp
jexp / StaticWebResource.java
Created April 24, 2015 17:04
Neo4j Server Extension that serves files from a webapp directory of the JAR
@Path("/")
public class StaticWebResource {
@GET
@Path("{file:(?i).+\\.(png|jpg|jpeg|svg|gif|html?|js|css|txt)}")
public Response file(@PathParam("file") String file) throws IOException {
InputStream fileStream = findFileStream(file);
if (fileStream == null) return Response.status(Response.Status.NOT_FOUND).build();
else return Response.ok(fileStream, mediaType(file)).build();
}