|
|
|
@ -1,18 +1,11 @@
|
|
|
|
|
using Nancy;
|
|
|
|
|
using Nancy.Bootstrapper;
|
|
|
|
|
using NzbDrone.Api.Frontend;
|
|
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api.Extensions.Pipelines
|
|
|
|
|
{
|
|
|
|
|
public class CacheHeaderPipeline : IRegisterNancyPipeline
|
|
|
|
|
public class NzbDroneVersionPipeline : IRegisterNancyPipeline
|
|
|
|
|
{
|
|
|
|
|
private readonly ICacheableSpecification _cacheableSpecification;
|
|
|
|
|
|
|
|
|
|
public CacheHeaderPipeline(ICacheableSpecification cacheableSpecification)
|
|
|
|
|
{
|
|
|
|
|
_cacheableSpecification = cacheableSpecification;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Register(IPipelines pipelines)
|
|
|
|
|
{
|
|
|
|
|
pipelines.AfterRequest.AddItemToStartOfPipeline(Handle);
|
|
|
|
@ -20,14 +13,7 @@ namespace NzbDrone.Api.Extensions.Pipelines
|
|
|
|
|
|
|
|
|
|
private void Handle(NancyContext context)
|
|
|
|
|
{
|
|
|
|
|
if (_cacheableSpecification.IsCacheable(context))
|
|
|
|
|
{
|
|
|
|
|
context.Response.Headers.EnableCache();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
context.Response.Headers.DisableCache();
|
|
|
|
|
}
|
|
|
|
|
context.Response.Headers.Add("X-ApplicationVersion", BuildInfo.Version.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|