Files
raven/server/AyaNova/Controllers/ApiRootController.cs
2018-10-16 18:09:14 +00:00

106 lines
3.2 KiB
C#

using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using AyaNova.Util;
using AyaNova.Biz;
namespace AyaNova.Api.Controllers
{
/// <summary>
/// Meta controller class
/// </summary>
[ApiVersion("8.0")]
[Route("api/v{version:apiVersion}/")]
public class ApiMetaController : Controller
{
private readonly ILogger<ApiMetaController> _log;
/// <summary>
///
/// </summary>
/// <param name="logger"></param>
public ApiMetaController(ILogger<ApiMetaController> logger)
{
_log = logger;
}
/// <summary>
/// AyaNova API documentation and manual
/// </summary>
/// <returns></returns>
[HttpGet]
public ContentResult Index()
{
var resp = $@"<html lang=""en"">
<head>
<meta charset=""utf-8"">
<meta name=""viewport"" content=""width=device-width, initial-scale=1, shrink-to-fit=no"">
<title>AyaNova server</title>
</head>
<body >
<div style=""text-align: center;"">
<div style=""display: inline-block;text-align:left;"">
<h1>{AyaNovaVersion.FullNameAndVersion}</h1>
<a href=""/"">AyaNova Client</a><br/><br/>
<a href=""/docs"">AyaNova manual</a><br/><br/>
<a href=""/api-docs"">API explorer</a><br/><br/>
<a href=""mailto:support@ayanova.com"">Email AyaNova support</a><br/><br/>
<h4>{LocaleBiz.GetDefaultLocalizedText("HelpLicense").Result}</h4>
<pre>{AyaNova.Core.License.LicenseInfo}</pre>
<h4>Schema version</h4>
<pre>{AySchema.currentSchema.ToString()}</pre>
<h4>Server time</h4>
<pre>{DateUtil.ServerDateTimeString(System.DateTime.UtcNow)}</pre>
<pre>{TimeZoneInfo.Local.Id}</pre>
<h4>Server logs</h4>
<pre>{ServerBootConfig.AYANOVA_LOG_PATH}</pre>
</div>
</div>
</body>
</html>";
return new ContentResult
{
ContentType = "text/html",
StatusCode = 200,
Content = resp
};
}
#if (DEBUG)
/// <summary>
/// Get build mode of server, used for automated testing purposes
///
/// Required roles: Any
///
/// </summary>
/// <returns>"DEBUG" or "RELEASE"</returns>
[HttpGet("BuildMode")]
public ActionResult BuildMode()
{
return Ok(new { result = new { BuildMode = "DEBUG" } });
}
#else
/// <summary>
/// Get build mode of server, used for automated testing purposes
///
/// Required roles: Any
///
/// </summary>
/// <returns>"DEBUG" or "RELEASE"</returns>
[HttpGet("BuildMode")]
public ActionResult BuildMode()
{
return Ok(new { result = new { BuildMode = "RELEASE" } });
}
#endif
}
}