mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-21 19:34:42 +01:00
Update HttpServer & AuthenticationSystem to use Javalin
This commit is contained in:
@@ -5,44 +5,39 @@ import emu.grasscutter.data.DataLoader;
|
||||
import emu.grasscutter.server.http.objects.HttpJsonResponse;
|
||||
import emu.grasscutter.server.http.Router;
|
||||
import emu.grasscutter.utils.FileUtils;
|
||||
import emu.grasscutter.utils.HttpUtils;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import express.Express;
|
||||
import express.http.MediaType;
|
||||
import express.http.Request;
|
||||
import express.http.Response;
|
||||
import io.javalin.Javalin;
|
||||
import io.javalin.http.Context;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Handles requests related to the announcements page.
|
||||
*/
|
||||
public final class AnnouncementsHandler implements Router {
|
||||
@Override public void applyRoutes(Express express, Javalin handle) {
|
||||
@Override public void applyRoutes(Javalin javalin) {
|
||||
// hk4e-api-os.hoyoverse.com
|
||||
express.all("/common/hk4e_global/announcement/api/getAlertPic", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"total\":0,\"list\":[]}}"));
|
||||
HttpUtils.allRoutes(javalin, "/common/hk4e_global/announcement/api/getAlertPic", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"total\":0,\"list\":[]}}"));
|
||||
// hk4e-api-os.hoyoverse.com
|
||||
express.all("/common/hk4e_global/announcement/api/getAlertAnn", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"alert\":false,\"alert_id\":0,\"remind\":true}}"));
|
||||
HttpUtils.allRoutes(javalin,"/common/hk4e_global/announcement/api/getAlertAnn", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"alert\":false,\"alert_id\":0,\"remind\":true}}"));
|
||||
// hk4e-api-os.hoyoverse.com
|
||||
express.all("/common/hk4e_global/announcement/api/getAnnList", AnnouncementsHandler::getAnnouncement);
|
||||
HttpUtils.allRoutes(javalin,"/common/hk4e_global/announcement/api/getAnnList", AnnouncementsHandler::getAnnouncement);
|
||||
// hk4e-api-os-static.hoyoverse.com
|
||||
express.all("/common/hk4e_global/announcement/api/getAnnContent", AnnouncementsHandler::getAnnouncement);
|
||||
HttpUtils.allRoutes(javalin,"/common/hk4e_global/announcement/api/getAnnContent", AnnouncementsHandler::getAnnouncement);
|
||||
// hk4e-sdk-os.hoyoverse.com
|
||||
express.all("/hk4e_global/mdk/shopwindow/shopwindow/listPriceTier", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"suggest_currency\":\"USD\",\"tiers\":[]}}"));
|
||||
HttpUtils.allRoutes(javalin,"/hk4e_global/mdk/shopwindow/shopwindow/listPriceTier", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"suggest_currency\":\"USD\",\"tiers\":[]}}"));
|
||||
|
||||
express.get("/hk4e/announcement/*", AnnouncementsHandler::getPageResources);
|
||||
javalin.get("/hk4e/announcement/*", AnnouncementsHandler::getPageResources);
|
||||
}
|
||||
|
||||
private static void getAnnouncement(Request request, Response response) {
|
||||
private static void getAnnouncement(Context ctx) {
|
||||
String data = "";
|
||||
if (Objects.equals(request.baseUrl(), "/common/hk4e_global/announcement/api/getAnnContent")) {
|
||||
if (Objects.equals(ctx.endpointHandlerPath(), "/common/hk4e_global/announcement/api/getAnnContent")) {
|
||||
try {
|
||||
data = FileUtils.readToString(DataLoader.load("GameAnnouncement.json"));
|
||||
} catch (Exception e) {
|
||||
@@ -50,7 +45,7 @@ public final class AnnouncementsHandler implements Router {
|
||||
Grasscutter.getLogger().info("Unable to read file 'GameAnnouncementList.json'. \n" + e);
|
||||
}
|
||||
}
|
||||
} else if (Objects.equals(request.baseUrl(), "/common/hk4e_global/announcement/api/getAnnList")) {
|
||||
} else if (Objects.equals(ctx.endpointHandlerPath(), "/common/hk4e_global/announcement/api/getAnnList")) {
|
||||
try {
|
||||
data = FileUtils.readToString(DataLoader.load("GameAnnouncementList.json"));
|
||||
} catch (Exception e) {
|
||||
@@ -59,11 +54,11 @@ public final class AnnouncementsHandler implements Router {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
response.send("{\"retcode\":404,\"message\":\"Unknown request path\"}");
|
||||
ctx.result("{\"retcode\":404,\"message\":\"Unknown request path\"}");
|
||||
}
|
||||
|
||||
if (data.isEmpty()) {
|
||||
response.send("{\"retcode\":500,\"message\":\"Unable to fetch requsted content\"}");
|
||||
ctx.result("{\"retcode\":500,\"message\":\"Unable to fetch requsted content\"}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -74,19 +69,19 @@ public final class AnnouncementsHandler implements Router {
|
||||
data = data
|
||||
.replace("{{DISPATCH_PUBLIC}}", dispatchDomain)
|
||||
.replace("{{SYSTEM_TIME}}", String.valueOf(System.currentTimeMillis()));
|
||||
response.send("{\"retcode\":0,\"message\":\"OK\",\"data\": " + data + "}");
|
||||
ctx.result("{\"retcode\":0,\"message\":\"OK\",\"data\": " + data + "}");
|
||||
}
|
||||
|
||||
private static void getPageResources(Request request, Response response) {
|
||||
try (InputStream filestream = DataLoader.load(request.path())) {
|
||||
String possibleFilename = Utils.toFilePath(DATA(request.path()));
|
||||
private static void getPageResources(Context ctx) {
|
||||
try (InputStream filestream = DataLoader.load(ctx.path())) {
|
||||
String possibleFilename = Utils.toFilePath(DATA(ctx.path()));
|
||||
|
||||
MediaType fromExtension = MediaType.getByExtension(possibleFilename.substring(possibleFilename.lastIndexOf(".") + 1));
|
||||
response.type((fromExtension != null) ? fromExtension.getMIME() : "application/octet-stream");
|
||||
response.send(filestream.readAllBytes());
|
||||
HttpUtils.MediaType fromExtension = HttpUtils.MediaType.getByExtension(possibleFilename.substring(possibleFilename.lastIndexOf(".") + 1));
|
||||
ctx.contentType((fromExtension != null) ? fromExtension.getMIME() : "application/octet-stream");
|
||||
ctx.result(filestream.readAllBytes());
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().warn("File does not exist: " + request.path());
|
||||
response.status(404);
|
||||
Grasscutter.getLogger().warn("File does not exist: " + ctx.path());
|
||||
ctx.status(404);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,11 @@ import emu.grasscutter.game.gacha.GachaBanner;
|
||||
import emu.grasscutter.game.gacha.GachaSystem;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.server.http.Router;
|
||||
import emu.grasscutter.tools.Tools;
|
||||
import emu.grasscutter.utils.FileUtils;
|
||||
import emu.grasscutter.utils.HttpUtils;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import express.Express;
|
||||
import express.http.Request;
|
||||
import express.http.Response;
|
||||
import io.javalin.Javalin;
|
||||
import io.javalin.http.Context;
|
||||
import io.javalin.http.staticfiles.Location;
|
||||
|
||||
import java.io.File;
|
||||
@@ -31,38 +29,38 @@ import static emu.grasscutter.utils.Language.translate;
|
||||
public final class GachaHandler implements Router {
|
||||
public static final String gachaMappings = DATA(Utils.toFilePath("gacha/mappings.js"));
|
||||
|
||||
@Override public void applyRoutes(Express express, Javalin handle) {
|
||||
express.get("/gacha", GachaHandler::gachaRecords);
|
||||
express.get("/gacha/details", GachaHandler::gachaDetails);
|
||||
@Override public void applyRoutes(Javalin javalin) {
|
||||
javalin.get("/gacha", GachaHandler::gachaRecords);
|
||||
javalin.get("/gacha/details", GachaHandler::gachaDetails);
|
||||
|
||||
express.useStaticFallback("/gacha/mappings", gachaMappings, Location.EXTERNAL);
|
||||
javalin._conf.addSinglePageRoot("/gacha/mappings", gachaMappings, Location.EXTERNAL);
|
||||
}
|
||||
|
||||
private static void gachaRecords(Request request, Response response) {
|
||||
private static void gachaRecords(Context ctx) {
|
||||
File recordsTemplate = new File(Utils.toFilePath(DATA("gacha/records.html")));
|
||||
if (!recordsTemplate.exists()) {
|
||||
Grasscutter.getLogger().warn("File does not exist: " + recordsTemplate);
|
||||
response.status(500);
|
||||
ctx.status(500);
|
||||
return;
|
||||
}
|
||||
|
||||
String sessionKey = request.query("s");
|
||||
String sessionKey = ctx.queryParam("s");
|
||||
Account account = DatabaseHelper.getAccountBySessionKey(sessionKey);
|
||||
if (account == null) {
|
||||
response.status(403).send("Requested account was not found");
|
||||
ctx.status(403).result("Requested account was not found");
|
||||
return;
|
||||
}
|
||||
Player player = Grasscutter.getGameServer().getPlayerByAccountId(account.getId());
|
||||
if (player == null) {
|
||||
response.status(403).send("No player associated with requested account");
|
||||
ctx.status(403).result("No player associated with requested account");
|
||||
return;
|
||||
}
|
||||
|
||||
int page = 0, gachaType = 0;
|
||||
if (request.query("p") != null)
|
||||
page = Integer.parseInt(request.query("p"));
|
||||
if (request.query("gachaType") != null)
|
||||
gachaType = Integer.parseInt(request.query("gachaType"));
|
||||
if (ctx.queryParam("p") != null)
|
||||
page = Integer.parseInt(ctx.queryParam("p"));
|
||||
if (ctx.queryParam("gachaType") != null)
|
||||
gachaType = Integer.parseInt(ctx.queryParam("gachaType"));
|
||||
|
||||
String records = DatabaseHelper.getGachaRecords(player.getUid(), page, gachaType).toString();
|
||||
long maxPage = DatabaseHelper.getGachaRecordsMaxPage(player.getUid(), page, gachaType);
|
||||
@@ -74,26 +72,27 @@ public final class GachaHandler implements Router {
|
||||
.replace("{{DATE}}", translate(player, "gacha.records.date"))
|
||||
.replace("{{ITEM}}", translate(player, "gacha.records.item"))
|
||||
.replace("{{LANGUAGE}}", Utils.getLanguageCode(account.getLocale()));
|
||||
response.send(template);
|
||||
ctx.contentType(HttpUtils.MediaType._html.getMIME());
|
||||
ctx.result(template);
|
||||
}
|
||||
|
||||
private static void gachaDetails(Request request, Response response) {
|
||||
private static void gachaDetails(Context ctx) {
|
||||
File detailsTemplate = new File(Utils.toFilePath(DATA("gacha/details.html")));
|
||||
if (!detailsTemplate.exists()) {
|
||||
Grasscutter.getLogger().warn("File does not exist: " + detailsTemplate);
|
||||
response.status(500);
|
||||
ctx.status(500);
|
||||
return;
|
||||
}
|
||||
|
||||
String sessionKey = request.query("s");
|
||||
String sessionKey = ctx.queryParam("s");
|
||||
Account account = DatabaseHelper.getAccountBySessionKey(sessionKey);
|
||||
if (account == null) {
|
||||
response.status(403).send("Requested account was not found");
|
||||
ctx.status(403).result("Requested account was not found");
|
||||
return;
|
||||
}
|
||||
Player player = Grasscutter.getGameServer().getPlayerByAccountId(account.getId());
|
||||
if (player == null) {
|
||||
response.status(403).send("No player associated with requested account");
|
||||
ctx.status(403).result("No player associated with requested account");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -107,7 +106,7 @@ public final class GachaHandler implements Router {
|
||||
.replace("{{LANGUAGE}}", Utils.getLanguageCode(account.getLocale()));
|
||||
|
||||
// Get the banner info for the banner we want.
|
||||
int scheduleId = Integer.parseInt(request.query("scheduleId"));
|
||||
int scheduleId = Integer.parseInt(ctx.queryParam("scheduleId"));
|
||||
GachaSystem manager = Grasscutter.getGameServer().getGachaSystem();
|
||||
GachaBanner banner = manager.getGachaBanners().get(scheduleId);
|
||||
|
||||
@@ -135,6 +134,7 @@ public final class GachaHandler implements Router {
|
||||
template = template.replace("{{THREE_STARS}}", "[" + String.join(",", threeStarItems) + "]");
|
||||
|
||||
// Done.
|
||||
response.send(template);
|
||||
ctx.contentType(HttpUtils.MediaType._html.getMIME());
|
||||
ctx.result(template);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,53 +7,52 @@ import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.server.http.objects.HttpJsonResponse;
|
||||
import emu.grasscutter.server.http.Router;
|
||||
import emu.grasscutter.server.http.objects.WebStaticVersionResponse;
|
||||
import express.Express;
|
||||
import express.http.Request;
|
||||
import express.http.Response;
|
||||
import emu.grasscutter.utils.HttpUtils;
|
||||
import io.javalin.Javalin;
|
||||
import io.javalin.http.Context;
|
||||
|
||||
/**
|
||||
* Handles all generic, hard-coded responses.
|
||||
*/
|
||||
public final class GenericHandler implements Router {
|
||||
@Override public void applyRoutes(Express express, Javalin handle) {
|
||||
@Override public void applyRoutes(Javalin javalin) {
|
||||
// hk4e-sdk-os.hoyoverse.com
|
||||
express.get("/hk4e_global/mdk/agreement/api/getAgreementInfos", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"marketing_agreements\":[]}}"));
|
||||
javalin.get("/hk4e_global/mdk/agreement/api/getAgreementInfos", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"marketing_agreements\":[]}}"));
|
||||
// hk4e-sdk-os.hoyoverse.com
|
||||
// this could be either GET or POST based on the observation of different clients
|
||||
express.all("/hk4e_global/combo/granter/api/compareProtocolVersion", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"modified\":true,\"protocol\":{\"id\":0,\"app_id\":4,\"language\":\"en\",\"user_proto\":\"\",\"priv_proto\":\"\",\"major\":7,\"minimum\":0,\"create_time\":\"0\",\"teenager_proto\":\"\",\"third_proto\":\"\"}}}"));
|
||||
HttpUtils.allRoutes(javalin, "/hk4e_global/combo/granter/api/compareProtocolVersion", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"modified\":true,\"protocol\":{\"id\":0,\"app_id\":4,\"language\":\"en\",\"user_proto\":\"\",\"priv_proto\":\"\",\"major\":7,\"minimum\":0,\"create_time\":\"0\",\"teenager_proto\":\"\",\"third_proto\":\"\"}}}"));
|
||||
|
||||
// api-account-os.hoyoverse.com
|
||||
express.post("/account/risky/api/check", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"id\":\"none\",\"action\":\"ACTION_NONE\",\"geetest\":null}}"));
|
||||
javalin.post("/account/risky/api/check", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"id\":\"none\",\"action\":\"ACTION_NONE\",\"geetest\":null}}"));
|
||||
|
||||
// sdk-os-static.hoyoverse.com
|
||||
express.get("/combo/box/api/config/sdk/combo", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"vals\":{\"disable_email_bind_skip\":\"false\",\"email_bind_remind_interval\":\"7\",\"email_bind_remind\":\"true\"}}}"));
|
||||
javalin.get("/combo/box/api/config/sdk/combo", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"vals\":{\"disable_email_bind_skip\":\"false\",\"email_bind_remind_interval\":\"7\",\"email_bind_remind\":\"true\"}}}"));
|
||||
// hk4e-sdk-os-static.hoyoverse.com
|
||||
express.get("/hk4e_global/combo/granter/api/getConfig", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"protocol\":true,\"qr_enabled\":false,\"log_level\":\"INFO\",\"announce_url\":\"https://webstatic-sea.hoyoverse.com/hk4e/announcement/index.html?sdk_presentation_style=fullscreen\\u0026sdk_screen_transparent=true\\u0026game_biz=hk4e_global\\u0026auth_appid=announcement\\u0026game=hk4e#/\",\"push_alias_type\":2,\"disable_ysdk_guard\":false,\"enable_announce_pic_popup\":true}}"));
|
||||
javalin.get("/hk4e_global/combo/granter/api/getConfig", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"protocol\":true,\"qr_enabled\":false,\"log_level\":\"INFO\",\"announce_url\":\"https://webstatic-sea.hoyoverse.com/hk4e/announcement/index.html?sdk_presentation_style=fullscreen\\u0026sdk_screen_transparent=true\\u0026game_biz=hk4e_global\\u0026auth_appid=announcement\\u0026game=hk4e#/\",\"push_alias_type\":2,\"disable_ysdk_guard\":false,\"enable_announce_pic_popup\":true}}"));
|
||||
// hk4e-sdk-os-static.hoyoverse.com
|
||||
express.get("/hk4e_global/mdk/shield/api/loadConfig", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"id\":6,\"game_key\":\"hk4e_global\",\"client\":\"PC\",\"identity\":\"I_IDENTITY\",\"guest\":false,\"ignore_versions\":\"\",\"scene\":\"S_NORMAL\",\"name\":\"原神海外\",\"disable_regist\":false,\"enable_email_captcha\":false,\"thirdparty\":[\"fb\",\"tw\"],\"disable_mmt\":false,\"server_guest\":false,\"thirdparty_ignore\":{\"tw\":\"\",\"fb\":\"\"},\"enable_ps_bind_account\":false,\"thirdparty_login_configs\":{\"tw\":{\"token_type\":\"TK_GAME_TOKEN\",\"game_token_expires_in\":604800},\"fb\":{\"token_type\":\"TK_GAME_TOKEN\",\"game_token_expires_in\":604800}}}}"));
|
||||
javalin.get("/hk4e_global/mdk/shield/api/loadConfig", new HttpJsonResponse("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"id\":6,\"game_key\":\"hk4e_global\",\"client\":\"PC\",\"identity\":\"I_IDENTITY\",\"guest\":false,\"ignore_versions\":\"\",\"scene\":\"S_NORMAL\",\"name\":\"原神海外\",\"disable_regist\":false,\"enable_email_captcha\":false,\"thirdparty\":[\"fb\",\"tw\"],\"disable_mmt\":false,\"server_guest\":false,\"thirdparty_ignore\":{\"tw\":\"\",\"fb\":\"\"},\"enable_ps_bind_account\":false,\"thirdparty_login_configs\":{\"tw\":{\"token_type\":\"TK_GAME_TOKEN\",\"game_token_expires_in\":604800},\"fb\":{\"token_type\":\"TK_GAME_TOKEN\",\"game_token_expires_in\":604800}}}}"));
|
||||
// Test api?
|
||||
// abtest-api-data-sg.hoyoverse.com
|
||||
express.post("/data_abtest_api/config/experiment/list", new HttpJsonResponse("{\"retcode\":0,\"success\":true,\"message\":\"\",\"data\":[{\"code\":1000,\"type\":2,\"config_id\":\"14\",\"period_id\":\"6036_99\",\"version\":\"1\",\"configs\":{\"cardType\":\"old\"}}]}"));
|
||||
javalin.post("/data_abtest_api/config/experiment/list", new HttpJsonResponse("{\"retcode\":0,\"success\":true,\"message\":\"\",\"data\":[{\"code\":1000,\"type\":2,\"config_id\":\"14\",\"period_id\":\"6036_99\",\"version\":\"1\",\"configs\":{\"cardType\":\"old\"}}]}"));
|
||||
|
||||
// log-upload-os.mihoyo.com
|
||||
express.all("/log/sdk/upload", new HttpJsonResponse("{\"code\":0}"));
|
||||
express.all("/sdk/upload", new HttpJsonResponse("{\"code\":0}"));
|
||||
express.post("/sdk/dataUpload", new HttpJsonResponse("{\"code\":0}"));
|
||||
HttpUtils.allRoutes(javalin, "/log/sdk/upload", new HttpJsonResponse("{\"code\":0}"));
|
||||
HttpUtils.allRoutes(javalin, "/sdk/upload", new HttpJsonResponse("{\"code\":0}"));
|
||||
javalin.post("/sdk/dataUpload", new HttpJsonResponse("{\"code\":0}"));
|
||||
// /perf/config/verify?device_id=xxx&platform=x&name=xxx
|
||||
express.all("/perf/config/verify", new HttpJsonResponse("{\"code\":0}"));
|
||||
HttpUtils.allRoutes(javalin, "/perf/config/verify", new HttpJsonResponse("{\"code\":0}"));
|
||||
|
||||
// webstatic-sea.hoyoverse.com
|
||||
express.get("/admin/mi18n/plat_oversea/*", new WebStaticVersionResponse());
|
||||
javalin.get("/admin/mi18n/plat_oversea/*", new WebStaticVersionResponse());
|
||||
|
||||
express.get("/status/server", GenericHandler::serverStatus);
|
||||
javalin.get("/status/server", GenericHandler::serverStatus);
|
||||
}
|
||||
|
||||
private static void serverStatus(Request request, Response response) {
|
||||
private static void serverStatus(Context ctx) {
|
||||
int playerCount = Grasscutter.getGameServer().getPlayers().size();
|
||||
int maxPlayer = ACCOUNT.maxPlayer;
|
||||
String version = GameConstants.VERSION;
|
||||
|
||||
response.send("{\"retcode\":0,\"status\":{\"playerCount\":" + playerCount + ",\"maxPlayer\":" + maxPlayer + ",\"version\":\"" + version + "\"}}");
|
||||
ctx.result("{\"retcode\":0,\"status\":{\"playerCount\":" + playerCount + ",\"maxPlayer\":" + maxPlayer + ",\"version\":\"" + version + "\"}}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
package emu.grasscutter.server.http.handlers;
|
||||
|
||||
import emu.grasscutter.server.http.Router;
|
||||
import express.Express;
|
||||
import express.http.Request;
|
||||
import express.http.Response;
|
||||
import io.javalin.Javalin;
|
||||
import io.javalin.http.Context;
|
||||
|
||||
/**
|
||||
* Handles logging requests made to the server.
|
||||
*/
|
||||
public final class LogHandler implements Router {
|
||||
@Override public void applyRoutes(Express express, Javalin handle) {
|
||||
@Override public void applyRoutes(Javalin javalin) {
|
||||
// overseauspider.yuanshen.com
|
||||
express.post("/log", LogHandler::log);
|
||||
javalin.post("/log", LogHandler::log);
|
||||
// log-upload-os.mihoyo.com
|
||||
express.post("/crash/dataUpload", LogHandler::log);
|
||||
javalin.post("/crash/dataUpload", LogHandler::log);
|
||||
}
|
||||
|
||||
private static void log(Request request, Response response) {
|
||||
|
||||
private static void log(Context ctx) {
|
||||
// TODO: Figure out how to dump request body and log to file.
|
||||
response.send("{\"code\":0}");
|
||||
ctx.result("{\"code\":0}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user