fork from 1.3
This commit is contained in:
25
FreeSR.Admin/Handlers/ConsolePageRequestHandler.cs
Normal file
25
FreeSR.Admin/Handlers/ConsolePageRequestHandler.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
namespace FreeSR.Admin.Handlers
|
||||
{
|
||||
using Ceen;
|
||||
using FreeSR.Admin.Service;
|
||||
|
||||
internal class ConsolePageRequestHandler : IHttpModule
|
||||
{
|
||||
public async Task<bool> HandleAsync(IHttpContext context)
|
||||
{
|
||||
context.Response.StatusCode = HttpStatusCode.OK;
|
||||
await context.Response.WriteAllAsync(CreateHTMLDocument(), "text/html");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string CreateHTMLDocument()
|
||||
{
|
||||
string baseString = HttpAdminService.ConsoleHTML;
|
||||
|
||||
return baseString.Replace("%SERVER_VERSION%", "v0.1.0 dev - experimental open source")
|
||||
.Replace("%GAME_VERSION%", "1.2.0");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
23
FreeSR.Admin/Handlers/ExecuteCommandRequestHandler.cs
Normal file
23
FreeSR.Admin/Handlers/ExecuteCommandRequestHandler.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace FreeSR.Admin.Handlers
|
||||
{
|
||||
using Ceen;
|
||||
using FreeSR.Admin.Command;
|
||||
using FreeSR.Shared.Command;
|
||||
|
||||
internal class ExecuteCommandRequestHandler : IHttpModule
|
||||
{
|
||||
public async Task<bool> HandleAsync(IHttpContext context)
|
||||
{
|
||||
var query = context.Request.QueryString;
|
||||
string command = query["command"];
|
||||
|
||||
var ctx = new AdminCommandContext();
|
||||
CommandManager.Instance.Invoke(ctx, command);
|
||||
|
||||
context.Response.StatusCode = HttpStatusCode.OK;
|
||||
await context.Response.WriteAllAsync(ctx.Message, "text/plain");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user