commit | author | age
|
9c5db9
|
1 |
/* |
U |
2 |
http-adoc - Asciidoctor extensions to jdk.httpserver |
|
3 |
Copyright (C) 2021 Ulrich Hilger |
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU Affero General Public License as |
|
7 |
published by the Free Software Foundation, either version 3 of the |
|
8 |
License, or (at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU Affero General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU Affero General Public License |
|
16 |
along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 |
package de.uhilger.httpserver.adoc; |
|
19 |
|
|
20 |
import com.sun.net.httpserver.HttpExchange; |
|
21 |
import de.uhilger.httpserver.base.handler.FileHandler; |
|
22 |
import java.io.IOException; |
|
23 |
import java.util.logging.Logger; |
|
24 |
|
|
25 |
/** |
|
26 |
* Der AdocHandler verwendet den FileHandler zur Auslieferung statischer |
|
27 |
* Inhalte und einen AdocFilter, um vorab zu pruefen, ob fuer eine |
|
28 |
* Asciidoctor-Quelldatei bereits eine HTML-Version vorliegt. Wenn nicht, |
|
29 |
* verwendet der AdocFilter den AdocActor, um eine HTML-Version zu erzeugen, |
|
30 |
* die dann vom AdocHandler mit Hilfe der Methoden des FileHandler |
|
31 |
* ausgeliefert werden kann. |
|
32 |
* |
|
33 |
* @author Ulrich Hilger |
|
34 |
* @version 1, 16.06.2021 |
|
35 |
*/ |
|
36 |
public class AdocHandler extends FileHandler { |
|
37 |
|
|
38 |
private static final Logger logger = Logger.getLogger(AdocHandler.class.getName()); |
|
39 |
|
|
40 |
public AdocHandler(String absoluteDirectoryPathAndName) { |
|
41 |
super(absoluteDirectoryPathAndName); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public void handle(HttpExchange e) throws IOException { |
|
46 |
logger.fine(e.getRequestURI().toString()); |
|
47 |
// hier ggf. noch etwas eigenes machen... |
|
48 |
super.handle(e); // zu FileHandler delegieren |
|
49 |
} |
|
50 |
|
|
51 |
public String getFileBase() { |
|
52 |
return this.fileBase; |
|
53 |
} |
|
54 |
|
|
55 |
|
|
56 |
} |