Files
UnrealEngineUWP/Engine/Source/Programs/Horde/Horde.Build/Server/ServerController.cs
Ben Marsh 84c453ad8f Horde: Move files into namespaces corresponding to their location on disk.
#preflight none

[CL 20543973 by Ben Marsh in ue5-main branch]
2022-06-07 15:53:33 -04:00

56 lines
1.3 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using System.Diagnostics;
using System.Reflection;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
namespace Horde.Build.Server
{
/// <summary>
/// Controller managing account status
/// </summary>
[ApiController]
[Authorize]
[Route("[controller]")]
public class ServerController : ControllerBase
{
/// <summary>
/// Settings for the server
/// </summary>
readonly IOptionsMonitor<ServerSettings> _settings;
/// <summary>
/// Constructor
/// </summary>
public ServerController(IOptionsMonitor<ServerSettings> settings)
{
_settings = settings;
}
/// <summary>
/// Get server version
/// </summary>
[HttpGet]
[Route("/api/v1/server/version")]
public ActionResult GetVersionAsync()
{
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
return Ok(fileVersionInfo.ProductVersion);
}
/// <summary>
/// Get server information
/// </summary>
[HttpGet]
[Route("/api/v1/server/info")]
[ProducesResponseType(typeof(GetServerInfoResponse), 200)]
public ActionResult<GetServerInfoResponse> GetServerInfo()
{
return new GetServerInfoResponse(_settings.CurrentValue.SingleInstance);
}
}
}