New: Ping Endpoint

pull/1453/head
Qstick 1 year ago
parent 6579385110
commit 5abb5ada49

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NzbDrone.Common.Cache;
using NzbDrone.Core.Configuration;
using Prowlarr.Http.Ping;
namespace Prowlarr.Http
{
public class PingController : Controller
{
private readonly IConfigRepository _configRepository;
private readonly ICached<IEnumerable<Config>> _cache;
public PingController(IConfigRepository configRepository, ICacheManager cacheManager)
{
_configRepository = configRepository;
_cache = cacheManager.GetCache<IEnumerable<Config>>(GetType());
}
[AllowAnonymous]
[HttpGet("/ping")]
[Produces("application/json")]
public ActionResult<PingResource> GetStatus()
{
try
{
_cache.Get("ping", _configRepository.All, TimeSpan.FromSeconds(5));
}
catch (Exception)
{
return StatusCode(StatusCodes.Status500InternalServerError, new PingResource
{
Status = "Error"
});
}
return StatusCode(StatusCodes.Status200OK, new PingResource
{
Status = "OK"
});
}
}
}

@ -0,0 +1,7 @@
namespace Prowlarr.Http.Ping
{
public class PingResource
{
public string Status { get; set; }
}
}
Loading…
Cancel
Save