25 lines
689 B
C#
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 ;
|
|
|
|
|
|
}
|
|
}
|
|
}
|