53 lines
1.7 KiB
C#
53 lines
1.7 KiB
C#
// <copyright file="ServerInfoController.cs" company="alveus.dev">
|
|
// Copyright (c) alveus.dev. All rights reserved. Licensed under the MIT License.
|
|
// </copyright>
|
|
|
|
using Astral.ApiServer.Models;
|
|
using Astral.ApiServer.Models.Responses;
|
|
using Astral.ApiServer.Options;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
namespace Astral.ApiServer.Controllers;
|
|
|
|
/// <summary>
|
|
/// Get information about this instance.
|
|
/// </summary>
|
|
[Route("api")]
|
|
public class ServerInfoController : BaseApiController
|
|
{
|
|
private readonly MetaverseInfoResponseModel _metaverseInfo;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ServerInfoController"/> class.
|
|
/// </summary>
|
|
/// <param name="metaverse">Instance of <see cref="IOptions{MetaverseInfoOptions}"/>.</param>
|
|
public ServerInfoController(IOptions<MetaverseInfoOptions> metaverse)
|
|
{
|
|
var options = metaverse.Value;
|
|
|
|
_metaverseInfo = new MetaverseInfoResponseModel()
|
|
{
|
|
MetaverseName = options.Name,
|
|
MetaverseNickName = options.Nickname,
|
|
MetaverseUrl = options.ServerUrl,
|
|
IceServerUrl = options.IceServerUrl,
|
|
Version = new MetaverseVersionModel()
|
|
{
|
|
Version = options.Version,
|
|
Codename = options.Codename
|
|
}
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get information about this metaverse instance.
|
|
/// </summary>
|
|
/// <returns>Instance of <see cref="MetaverseInfoResponseModel"/>.</returns>
|
|
[HttpGet("metaverse_info")]
|
|
[HttpGet("v1/metaverse_info")]
|
|
public IActionResult GetMetaverseInformation()
|
|
{
|
|
return new JsonResult(_metaverseInfo);
|
|
}
|
|
}
|