Web interface: использование логгера вместо stdout
This commit is contained in:
@@ -6,17 +6,21 @@ package asys.webinterface;
|
|||||||
|
|
||||||
import com.sun.net.httpserver.HttpExchange;
|
import com.sun.net.httpserver.HttpExchange;
|
||||||
import com.sun.net.httpserver.HttpHandler;
|
import com.sun.net.httpserver.HttpHandler;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
public class StaticHandler implements HttpHandler {
|
public class StaticHandler implements HttpHandler {
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(StaticHandler.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(HttpExchange httpExchange) throws IOException {
|
public void handle(HttpExchange httpExchange) throws IOException {
|
||||||
String fileId = httpExchange.getRequestURI().getPath();
|
String fileId = httpExchange.getRequestURI().getPath();
|
||||||
fileId = fileId.replace("../", "").replace("//", "/");
|
fileId = fileId.replace("../", "").replace("//", "/");
|
||||||
System.err.println(fileId);
|
logger.debug(fileId);
|
||||||
InputStream inputStream = getClass().getResourceAsStream(fileId);
|
InputStream inputStream = getClass().getResourceAsStream(fileId);
|
||||||
if (inputStream == null) {
|
if (inputStream == null) {
|
||||||
String response = "Error 404 File not found.";
|
String response = "Error 404 File not found.";
|
||||||
|
|||||||
Reference in New Issue
Block a user