?
This commit is contained in:
39
Api/InfoController.cs
Normal file
39
Api/InfoController.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user