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/ShowThreads.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
851 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 ThreadsController : ControllerBase
{
[HttpGet(Name = "GetThreads")]
public string Get([FromUri] string board)
{
string ipAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
List<Post> posts = DBchat.ThreadsList(board);
string postsJson = JsonSerializer.Serialize(posts);
Console.WriteLine("С адреса " + ipAddress + " запрошен список тредов из борды " + board);
return postsJson;
}
}
}