get my ip test

This commit is contained in:
Mikhail Trubnikov
2023-08-01 16:00:33 +10:00
parent 4f9410e975
commit 04c4ed594d
2 changed files with 41 additions and 2 deletions

View File

@@ -41,6 +41,13 @@
public const string getParam = "{id}"; public const string getParam = "{id}";
} }
public static class Test
{
public const string GetMyIp = Base + "/tests/my-ip";
}
//public static class Layer //public static class Layer
//{ //{
// public const string GetAll = Base + "/layers/"; // public const string GetAll = Base + "/layers/";

View File

@@ -0,0 +1,32 @@
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 ip = ipAddress?.ToString();
return Ok(new Response<object>(new { ip }, true));
}
}
}