Skip to content

Commit

Permalink
Fix 400 returned when server is not found (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
3Mydlo3 authored Sep 14, 2024
1 parent aacded7 commit 1f225a0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ArmaForces.ArmaServerManager/Api/Servers/ServersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public async Task<IActionResult> SetHeadlessClients(int port, HeadlessSetRequest

return result.Match(
onSuccess: NoContent,
onFailure: error => (IActionResult) BadRequest(error));
onFailure: error => (IActionResult) NotFound(error));
}

/// <summary>Restart Server</summary>
Expand All @@ -127,14 +127,15 @@ public async Task<IActionResult> SetHeadlessClients(int port, HeadlessSetRequest
/// <param name="serverRestartRequestDto">Additional details.</param>
[HttpPost("{port:int}/restart", Name = nameof(RestartServer))]
[ProducesResponseType(typeof(int), StatusCodes.Status202Accepted)]
[ProducesResponseType(typeof(string), StatusCodes.Status404NotFound)]
[ProducesResponseType(typeof(string), StatusCodesExtended.Status425TooEarly)]
[ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
[ApiKey]
public IActionResult RestartServer(int port, ServerRestartRequestDto serverRestartRequestDto)
{
var serverGetResult = _serverQueryLogic.GetServer(port);

if (serverGetResult.IsFailure) return BadRequest("Server is not running and cannot be restarted.");
if (serverGetResult.IsFailure) return NotFound("Server is not running and cannot be restarted.");

var server = serverGetResult.Value;

Expand Down

0 comments on commit 1f225a0

Please sign in to comment.