2021-06-04 11:36:14 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
2022-03-23 14:50:23 -04:00
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Reflection;
|
2022-03-16 11:18:39 -04:00
|
|
|
using Horde.Build.Api;
|
2021-06-04 11:36:14 -04:00
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
|
2022-03-16 11:18:39 -04:00
|
|
|
namespace Horde.Build.Controllers
|
2021-06-04 11:36:14 -04:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Controller managing account status
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiController]
|
|
|
|
|
[Authorize]
|
|
|
|
|
[Route("[controller]")]
|
|
|
|
|
public class ServerController : ControllerBase
|
|
|
|
|
{
|
2021-08-19 13:39:38 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Settings for the server
|
|
|
|
|
/// </summary>
|
2022-03-23 14:50:23 -04:00
|
|
|
readonly IOptionsMonitor<ServerSettings> _settings;
|
2021-08-19 13:39:38 -04:00
|
|
|
|
2021-06-04 11:36:14 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Constructor
|
|
|
|
|
/// </summary>
|
2022-03-23 14:50:23 -04:00
|
|
|
public ServerController(IOptionsMonitor<ServerSettings> settings)
|
2021-06-04 11:36:14 -04:00
|
|
|
{
|
2022-03-23 14:50:23 -04:00
|
|
|
_settings = settings;
|
2021-06-04 11:36:14 -04:00
|
|
|
}
|
2021-08-19 13:39:38 -04:00
|
|
|
|
2021-06-04 11:36:14 -04:00
|
|
|
/// <summary>
|
2021-08-19 13:39:38 -04:00
|
|
|
/// Get server version
|
2021-06-04 11:36:14 -04:00
|
|
|
/// </summary>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Route("/api/v1/server/version")]
|
|
|
|
|
public ActionResult GetVersionAsync()
|
|
|
|
|
{
|
2022-03-23 14:50:23 -04:00
|
|
|
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
|
|
|
|
|
return Ok(fileVersionInfo.ProductVersion);
|
2021-08-19 13:39:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get server information
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Route("/api/v1/server/info")]
|
|
|
|
|
[ProducesResponseType(typeof(GetServerInfoResponse), 200)]
|
|
|
|
|
public ActionResult<GetServerInfoResponse> GetServerInfo()
|
|
|
|
|
{
|
2022-03-23 14:50:23 -04:00
|
|
|
return new GetServerInfoResponse(_settings.CurrentValue.SingleInstance);
|
2021-06-04 11:36:14 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|