Archived
0

Web interface: использование логгера вместо stdout

This commit is contained in:
2017-03-08 12:45:26 +03:00
parent e4f89404ef
commit c216a4193c

View File

@@ -6,17 +6,21 @@ package asys.webinterface;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class StaticHandler implements HttpHandler {
private final Logger logger = LoggerFactory.getLogger(StaticHandler.class);
@Override
public void handle(HttpExchange httpExchange) throws IOException {
String fileId = httpExchange.getRequestURI().getPath();
fileId = fileId.replace("../", "").replace("//", "/");
System.err.println(fileId);
logger.debug(fileId);
InputStream inputStream = getClass().getResourceAsStream(fileId);
if (inputStream == null) {
String response = "Error 404 File not found.";