Skip to content

Instantly share code, notes, and snippets.

Avatar

Ralf Becher ralfbecher

View GitHub Profile
@jexp
jexp / StaticWebResource.java
Created Apr 24, 2015
Neo4j Server Extension that serves files from a webapp directory of the JAR
View StaticWebResource.java
@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();
}
You can’t perform that action at this time.