Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change 400 Bad Request to 404 Not Found when server is not found #98

Merged
merged 2 commits into from
Sep 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading