mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-12 12:24:35 +01:00
Allow the http server to serve static files (such as downloadable resources)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -63,6 +63,7 @@ tmp/
|
||||
/plugins
|
||||
/proto
|
||||
/resources
|
||||
/web
|
||||
|
||||
# Compiled
|
||||
/*.jar
|
||||
|
||||
@@ -24,6 +24,7 @@ public class Config {
|
||||
|
||||
public int customDataVersion = 0;
|
||||
public String resourceDir = "./resources";
|
||||
public String webFilesDir = "./web";
|
||||
public String patchListPath = "./patchlist.json";
|
||||
|
||||
@Getter
|
||||
|
||||
@@ -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