Files
parr_api/PARR.API/Controllers/V1/TestController.cs
Mikhail Trubnikov f3538fdd5d get ip v4
2023-08-01 16:30:16 +10:00

36 lines
902 B
C#

using Microsoft.AspNetCore.Mvc;
using PARR.API.Contracts.V1;
using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.API.Services.Interfaces;
namespace PARR.API.Controllers.V1
{
public class TestController : BaseApiController
{
private readonly IClientService clientService;
public TestController(IClientService clientService)
{
this.clientService = clientService;
}
/// <summary>
/// Получить мой ip
/// </summary>
/// <returns></returns>
[HttpGet(ApiRoutes.Test.GetMyIp)]
public IActionResult GetMyIp()
{
var ipAddress = clientService.GetClientIp();
//var ipV4 = ipAddress?.MapToIPv4();
var ip = ipAddress?.ToString();
return Ok(new Response<object>(new { ip }, true));
}
}
}