add dir option to FileServer

This commit is contained in:
Daniella / Tove 2022-07-07 13:59:09 +02:00
parent 8eca83854d
commit 5775f625c9
2 changed files with 6 additions and 9 deletions

View file

@ -4,17 +4,14 @@ import java.net.Socket;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Node;
import de.tudbut.async.Callback; import de.tudbut.async.Callback;
import de.tudbut.async.ComposeCallback; import de.tudbut.async.ComposeCallback;
import de.tudbut.async.TaskCallable; import de.tudbut.async.TaskCallable;
import de.tudbut.tryumph.config.IRequestCatcher; import de.tudbut.tryumph.config.IRequestCatcher;
import de.tudbut.tryumph.events.GET; import de.tudbut.tryumph.events.GET;
import de.tudbut.tryumph.events.POST;
import de.tudbut.tryumph.events.Path; import de.tudbut.tryumph.events.Path;
import de.tudbut.tryumph.events.RequestHandler; import de.tudbut.tryumph.events.RequestHandler;
import de.tudbut.tryumph.server.HTMLParsing;
import de.tudbut.tryumph.server.Request; import de.tudbut.tryumph.server.Request;
import de.tudbut.tryumph.server.Response; import de.tudbut.tryumph.server.Response;
import tudbut.parsing.TCN; import tudbut.parsing.TCN;
@ -62,7 +59,7 @@ public class FileServer implements IRequestCatcher, RequestHandler.Listener {
@GET @GET
@Path("/.*") @Path("/.*")
public void onIndex(Request request, Callback<Response> res, Callback<Throwable> rej) { public void onIndex(Request request, Callback<Response> res, Callback<Throwable> rej) {
res.call(new Response(request, request.context.file("." + request.path.replace("..", "")), 200, "OK")); res.call(new Response(request, request.context.file(data.getString("dir") + request.path.replace("..", "")), 200, "OK"));
} }
@Override @Override