|
|
@ -1,6 +1,9 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
using NzbDrone.Common.Cache;
|
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Lidarr.Http.Ping
|
|
|
|
namespace Lidarr.Http.Ping
|
|
|
@ -8,19 +11,22 @@ namespace Lidarr.Http.Ping
|
|
|
|
public class PingController : Controller
|
|
|
|
public class PingController : Controller
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly IConfigRepository _configRepository;
|
|
|
|
private readonly IConfigRepository _configRepository;
|
|
|
|
|
|
|
|
private readonly ICached<IEnumerable<Config>> _cache;
|
|
|
|
|
|
|
|
|
|
|
|
public PingController(IConfigRepository configRepository)
|
|
|
|
public PingController(IConfigRepository configRepository, ICacheManager cacheManager)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_configRepository = configRepository;
|
|
|
|
_configRepository = configRepository;
|
|
|
|
|
|
|
|
_cache = cacheManager.GetCache<IEnumerable<Config>>(GetType());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
[HttpGet("/ping")]
|
|
|
|
[HttpGet("/ping")]
|
|
|
|
[Produces("application/json")]
|
|
|
|
[Produces("application/json")]
|
|
|
|
public ActionResult<PingResource> GetStatus()
|
|
|
|
public ActionResult<PingResource> GetStatus()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_configRepository.All();
|
|
|
|
_cache.Get("ping", _configRepository.All, TimeSpan.FromSeconds(5));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception)
|
|
|
|
catch (Exception)
|
|
|
|
{
|
|
|
|
{
|
|
|
|