Add fake update

This commit is contained in:
jiych1
2022-07-02 21:00:49 +08:00
parent ccdb5d3754
commit c2258a5fd9
3 changed files with 30 additions and 1 deletions
@@ -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";
@@ -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";
}
}
}
+4 -1
View File
@@ -41,6 +41,8 @@ public class Server
module => module.WithController<ServerController>())
.WithWebApi(Configs.RANK_BASE_ROUTE, CustomResponseSerializer.None(true),
module => module.WithController<RankController>())
.WithWebApi(Configs.UPDATE_SERVICE_BASE_ROUTE, CustomResponseSerializer.None(true),
module => module.WithController<UpdateController>())
.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: