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 f791625102
All checks were successful
continuous-integration/drone/push Build is passing
Added threads listing controller
2022-11-24 12:56:07 +10:00

24 lines
896 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.PostsList(board, thread);
string postsJson = JsonSerializer.Serialize(posts);
Console.WriteLine("С адреса " + ipAddress + " запрошен список постов из борды " + board + " и треда# " + thread);
return postsJson ;
}
}
}