From f5adf51f59628c210d6bc8838df99d9b64002ee5 Mon Sep 17 00:00:00 2001
From: ulrich
Date: Fri, 25 Jun 2021 09:55:05 +0000
Subject: [PATCH] Logik in den Actor ausgelagert

---
 src/de/uhilger/httpserver/adoc/AdocHandler.java |   28 ++++++++++++++++++++++------
 1 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/de/uhilger/httpserver/adoc/AdocHandler.java b/src/de/uhilger/httpserver/adoc/AdocHandler.java
index dc20617..6edfb7a 100644
--- a/src/de/uhilger/httpserver/adoc/AdocHandler.java
+++ b/src/de/uhilger/httpserver/adoc/AdocHandler.java
@@ -20,6 +20,7 @@
 import com.sun.net.httpserver.HttpExchange;
 import de.uhilger.httpserver.base.handler.FileHandler;
 import java.io.IOException;
+import java.net.URI;
 import java.util.logging.Logger;
 
 /**
@@ -43,14 +44,29 @@
 
   @Override
   public void handle(HttpExchange e) throws IOException {
-    logger.fine(e.getRequestURI().toString());
-    // hier ggf. noch etwas eigenes machen...
-    super.handle(e); // zu FileHandler delegieren
+    URI uri = e.getRequestURI();
+    logger.fine(uri.toString());
+    String query = uri.getQuery();
+    //String[] params = query.split("?&"); // hier noch Regex ermitteln
+    String requestPathStr = uri.getPath();
+    //logger.fine("filter: " + requestUriStr);    
+    if(requestPathStr.toLowerCase().endsWith(AdocFilter.ADOC)) {
+      AdocActor actor = new AdocActor();
+      actor.handle(e, fileBase, getFileName(e));
+      /*
+      File adocfile = new File(fileBase, getFileName(e));
+      logger.fine("adocfile: " + adocfile.getAbsolutePath());
+      AdocActor actor = new AdocActor();
+      File outfile = actor.getTargetFile(adocfile, AdocActor.HTML);
+      logger.fine("outfile: " + outfile.getAbsolutePath());
+      HttpResponder fs = new HttpResponder();
+      fs.serveFile(e, outfile);
+      */
+    } else {
+      super.handle(e); // andere Inhalte zu FileHandler delegieren
+    }
   }
   
-  public String getFileBase() {
-    return this.fileBase;
-  }
   
   
 }

--
Gitblit v1.9.3