mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-25 10:44:37 +01:00
Allow the http server to serve static files (such as downloadable resources)
This commit is contained in:
@@ -19,6 +19,7 @@ import emu.nebula.util.JsonUtils;
|
||||
import io.javalin.Javalin;
|
||||
import io.javalin.http.ContentType;
|
||||
import io.javalin.http.Context;
|
||||
import io.javalin.http.staticfiles.Location;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@@ -32,8 +33,13 @@ public class HttpServer {
|
||||
private byte[] diff;
|
||||
|
||||
public HttpServer(ServerType type) {
|
||||
this.app = Javalin.create();
|
||||
this.type = type;
|
||||
this.app = Javalin.create(javalinConfig -> {
|
||||
var staticFilesDir = new File(Nebula.getConfig().getWebFilesDir());
|
||||
if (staticFilesDir.exists()) {
|
||||
javalinConfig.staticFiles.add(staticFilesDir.getPath(), Location.EXTERNAL);
|
||||
}
|
||||
});
|
||||
|
||||
this.loadPatchList();
|
||||
this.addRoutes();
|
||||
|
||||
Reference in New Issue
Block a user