add index to FileServer

This commit is contained in:
Daniella / Tove 2022-07-07 15:50:29 +02:00
parent c1b8e59da6
commit 65289927b0

View file

@ -63,8 +63,14 @@ 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(data.getString("dir") + request.path.replace("..", "") + "/index.html"), 200, "OK"));
}
@GET
@Path("/.+")
public void onFile(Request request, Callback<Response> res, Callback<Throwable> rej) {
res.call(new Response(request, request.context.file(data.getString("dir") + request.path.replace("..", "")), 200, "OK")); res.call(new Response(request, request.context.file(data.getString("dir") + request.path.replace("..", "")), 200, "OK"));
} }