This repository has been archived on 2023-06-30. You can view files and clone it, but cannot push or open issues or pull requests.
2chBackAPI/Controllers/GetPosts.cs
Simple_Not 0dc55aa9df
Some checks failed
continuous-integration/drone/push Build is failing
getting ip addresses
2022-11-02 00:58:07 +10:00

25 lines
689 B
C#

using Microsoft.AspNetCore.Mvc;
using System.Text.Json;
namespace NeDvachAPI.Controllers
{
[ApiController]
[Route("[controller]")]
public class ListController : ControllerBase
{
[HttpGet(Name = "GetPosts")]
public string Get()
{
var remoteIpAddress = httpContext.GetFeature<IHttpConnectionFeature>()?.RemoteIpAddress;
//Post[] posts = DBchat.DbList();
List<Post> posts = DBchat.DbList();
string postsJson = JsonSerializer.Serialize(posts);
Console.WriteLine($"Запрошен список постов для {remoteIpAddress}");
return postsJson ;
}
}
}