Beispiel #1
0
 /** {@inheritDoc} */
 @Override
 public Response handleRequest(REQ request, Response response) throws IOException {
   String path = request.getUri().getPath();
   int lastSlash = path.lastIndexOf('/');
   String filename = path.substring(lastSlash + 1);
   InputStream fileInputStream = getClass().getResourceAsStream(resourcePathPrefix + filename);
   if (fileInputStream == null) {
     return response.setStatusCode(404).setStatusText("Not found.");
   }
   StreamCopier.copy(fileInputStream, response.getContent());
   return response.setStatusCode(200).setStatusText("OK").setContentType(mimeType);
 }