Started with adding container creation and a server state machine

This commit is contained in:
2024-12-26 21:09:22 +01:00
parent 9f8c1f6d24
commit 039db22207
12 changed files with 548 additions and 32 deletions

View File

@@ -0,0 +1,29 @@
using Microsoft.AspNetCore.Mvc;
using MoonCore.Exceptions;
using MoonlightServers.Daemon.Models;
using MoonlightServers.Daemon.Services;
namespace MoonlightServers.Daemon.Http.Controllers.Servers;
[ApiController]
[Route("api/servers")]
public class ServersController : Controller
{
private readonly ServerService ServerService;
public ServersController(ServerService serverService)
{
ServerService = serverService;
}
[HttpPost("{serverId}/start")]
public async Task Start(int serverId)
{
var server = ServerService.GetServer(serverId);
if (server == null)
throw new HttpApiException("No server with this id found", 404);
await server.StateMachine.TransitionTo(ServerState.Starting);
}
}