diff --git a/PARR.API/Contracts/V1/ApiRoutes.cs b/PARR.API/Contracts/V1/ApiRoutes.cs index eed30a21..5c0482dc 100644 --- a/PARR.API/Contracts/V1/ApiRoutes.cs +++ b/PARR.API/Contracts/V1/ApiRoutes.cs @@ -41,6 +41,13 @@ public const string getParam = "{id}"; } + public static class Test + { + public const string GetMyIp = Base + "/tests/my-ip"; + + } + + //public static class Layer //{ // public const string GetAll = Base + "/layers/"; @@ -52,6 +59,6 @@ // public const string getParam = "{id}"; // - } - } + +} diff --git a/PARR.API/Controllers/V1/TestController.cs b/PARR.API/Controllers/V1/TestController.cs new file mode 100644 index 00000000..b4b2b811 --- /dev/null +++ b/PARR.API/Controllers/V1/TestController.cs @@ -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; + } + + + /// + /// Получить мой ip + /// + /// + [HttpGet(ApiRoutes.Test.GetMyIp)] + public IActionResult GetMyIp() + { + var ipAddress = clientService.GetClientIp(); + var ip = ipAddress?.ToString(); + + return Ok(new Response(new { ip }, true)); + } + } +}