39 lines
987 B
C#
39 lines
987 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace CatLink.Api
|
|
{
|
|
public class RelayInfoResponse
|
|
{
|
|
[JsonPropertyName("relayHost")]
|
|
public string RelayHost { get; set; } = string.Empty;
|
|
|
|
[JsonPropertyName("relayPort")]
|
|
public int RelayPort { get; set; }
|
|
}
|
|
|
|
[ApiController]
|
|
[Route("info")]
|
|
public class InfoController : ControllerBase
|
|
{
|
|
private readonly IConfiguration _configuration;
|
|
|
|
public InfoController(IConfiguration configuration)
|
|
{
|
|
_configuration = configuration;
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult GetInfo()
|
|
{
|
|
var host = _configuration.GetValue<string>("Host") ?? "localhost";
|
|
var relayPort = _configuration.GetValue<int>("RelayPort");
|
|
|
|
return Ok(new RelayInfoResponse
|
|
{
|
|
RelayHost = host,
|
|
RelayPort = relayPort
|
|
});
|
|
}
|
|
}
|
|
} |