From 0de53ac0c2118e6820ac7df309ee86ca69982483 Mon Sep 17 00:00:00 2001 From: ulrich Date: Thu, 24 Jun 2021 12:26:35 +0000 Subject: [PATCH] getFileBase in den FileHandler verlegt --- src/de/uhilger/httpserver/adoc/AdocHandler.java | 26 ++++++++++++++++++++------ 1 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/de/uhilger/httpserver/adoc/AdocHandler.java b/src/de/uhilger/httpserver/adoc/AdocHandler.java index dc20617..88b0589 100644 --- a/src/de/uhilger/httpserver/adoc/AdocHandler.java +++ b/src/de/uhilger/httpserver/adoc/AdocHandler.java @@ -18,8 +18,11 @@ package de.uhilger.httpserver.adoc; import com.sun.net.httpserver.HttpExchange; +import de.uhilger.httpserver.base.HttpResponder; import de.uhilger.httpserver.base.handler.FileHandler; +import java.io.File; import java.io.IOException; +import java.net.URI; import java.util.logging.Logger; /** @@ -43,14 +46,25 @@ @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)) { + 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