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.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.";
|
||||
|
||||
Reference in New Issue
Block a user