diff --git a/GC-local-server-rewrite/common/Configs.cs b/GC-local-server-rewrite/common/Configs.cs index 3ca1c3b..fbc94d6 100644 --- a/GC-local-server-rewrite/common/Configs.cs +++ b/GC-local-server-rewrite/common/Configs.cs @@ -36,6 +36,8 @@ public static class Configs public const string INCOM_SERVICE_BASE_ROUTE = "/service/incom"; + public const string UPDATE_SERVICE_BASE_ROUTE = "/update/cgi"; + public const string RANK_BASE_ROUTE = "/ranking"; public const string ALIVE_BASE_ROUTE = "/alive"; diff --git a/GC-local-server-rewrite/controllers/UpdateController.cs b/GC-local-server-rewrite/controllers/UpdateController.cs new file mode 100644 index 0000000..b079421 --- /dev/null +++ b/GC-local-server-rewrite/controllers/UpdateController.cs @@ -0,0 +1,24 @@ +using EmbedIO; +using EmbedIO.Routing; +using EmbedIO.WebApi; +using Swan.Logging; + +namespace GCLocalServerRewrite.controllers +{ + // TODO: Add proper update check response + public class UpdateController : WebApiController + { + [Route(HttpVerbs.Get, "/check.php")] + public string CheckUpdate() + { + var parameters = HttpContext.GetRequestQueryData(); + foreach (var key in parameters.AllKeys) + { + $"Key {key}: {parameters[key]}".Info(); + } + + HttpContext.Response.StatusCode = 404; + return "Not found"; + } + } +} diff --git a/GC-local-server-rewrite/server/Server.cs b/GC-local-server-rewrite/server/Server.cs index 1f652fc..0c7e84d 100644 --- a/GC-local-server-rewrite/server/Server.cs +++ b/GC-local-server-rewrite/server/Server.cs @@ -41,6 +41,8 @@ public class Server module => module.WithController()) .WithWebApi(Configs.RANK_BASE_ROUTE, CustomResponseSerializer.None(true), module => module.WithController()) + .WithWebApi(Configs.UPDATE_SERVICE_BASE_ROUTE, CustomResponseSerializer.None(true), + module => module.WithController()) .WithStaticFolder(Configs.STATIC_BASE_ROUTE, PathHelper.HtmlRootPath, true, m => m .WithContentCaching(Configs.USE_FILE_CACHE)) // Add static files after other modules to avoid conflicts @@ -62,7 +64,8 @@ public class Server switch (exception.StatusCode) { case 404: - await context.SendStringAsync("404 NOT FOUND!", "text/html", new UTF8Encoding(false)); + var htmlContents = await File.ReadAllTextAsync(Path.Combine(PathHelper.HtmlRootPath, "index.html")); + await context.SendStringAsync(htmlContents, "text/html", Encoding.UTF8); break; default: