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
RakVhalate 6da7a84cab
All checks were successful
continuous-integration/drone/push Build is passing
added Ip logging
2022-11-22 18:03:38 +10:00

24 lines
893 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Microsoft.AspNetCore.Mvc;
using System.Text.Json;
using System.Web.Http;
using HttpGetAttribute = Microsoft.AspNetCore.Mvc.HttpGetAttribute;
using RouteAttribute = Microsoft.AspNetCore.Mvc.RouteAttribute;
namespace NeDvachAPI.Controllers
{
[ApiController]
[Route("[controller]")]
public class ListController : ControllerBase
{
[HttpGet(Name = "GetPosts")]
public string Get([FromUri] string board, int thread)
{
string ipAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
List<Post> posts = DBchat.DbList(board, thread);
string postsJson = JsonSerializer.Serialize(posts);
Console.WriteLine("С адреса " + ipAddress + " запрошен список постов из борды " + board + " и треда# " + thread);
return postsJson ;
}
}
}