mirror of
https://github.com/volodymyrsmirnov/MalwareMultiScan.git
synced 2025-08-24 05:22:22 +00:00
41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using MalwareMultiScan.Api.Data.Configuration;
|
|
using MalwareMultiScan.Api.Data.Response;
|
|
using MalwareMultiScan.Api.Services;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace MalwareMultiScan.Api.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("backends")]
|
|
[Produces("application/json")]
|
|
public class ScanBackendsController : Controller
|
|
{
|
|
private readonly ScanBackendService _scanBackendService;
|
|
|
|
public ScanBackendsController(ScanBackendService scanBackendService)
|
|
{
|
|
_scanBackendService = scanBackendService;
|
|
}
|
|
|
|
private async Task<ScanBackendResponse> GetScanBackendResponse(ScanBackend backend)
|
|
{
|
|
return new ScanBackendResponse
|
|
{
|
|
Id = backend.Id,
|
|
Name = backend.Name,
|
|
Online = await _scanBackendService.Ping(backend)
|
|
};
|
|
}
|
|
|
|
[HttpGet]
|
|
[ProducesResponseType(typeof(ScanBackendResponse[]), StatusCodes.Status200OK)]
|
|
public async Task<IActionResult> Index()
|
|
{
|
|
return Ok(await Task.WhenAll(
|
|
_scanBackendService.List.Select(GetScanBackendResponse).ToArray()));
|
|
}
|
|
}
|
|
} |