Bilder mit Neon 2 verwenden
ulrich
2024-02-25 f7b9adf186cdda03ef787dd8064066e790710a69
src/de/uhilger/neon/image/ImageFilter.java
@@ -60,18 +60,26 @@
  
  @Override
  public void doFilter(HttpExchange exchange, Chain chain) throws IOException {
    /*
      Regex fuer Bilder
      .+\.jpg|.+\.jpeg|.+\.png
      (Testen z.B. auf https://regexr.com/)
    */
    String pattern = (String) exchange.getHttpContext().getAttributes()
            .getOrDefault("imageFilterPattern", ".+\\.jpg|.+\\.jpeg|.+\\.png");
    String uriStr = exchange.getRequestURI().toString();
    //String fName = new HttpHelper().getFileName(exchange);
    String fName = exchange
            .getRequestURI()
            .getPath()
            .substring(exchange
                    .getHttpContext()
                    .getPath()
                    .length());
    ImageWorker worker = new ImageWorker();
    worker.createImages(exchange.getHttpContext().getAttributes().get(FileServer.ATTR_FILE_BASE).toString(),
            fName, uriStr);
    if(uriStr.matches(pattern)) {
      String fileBase = (String) exchange.getHttpContext().getAttributes()
              .get(FileServer.ATTR_FILE_BASE);
      String fileName = exchange
              .getRequestURI()
              .getPath()
              .substring(exchange
                      .getHttpContext()
                      .getPath()
                      .length());
      new ImageWorker().createImages(fileBase, fileName, uriStr);
    }
    chain.doFilter(exchange);
  }