Order the pipeline registration process.

This commit is contained in:
Taloth Saldono 2016-07-24 00:48:04 +02:00
parent a2536deef0
commit 19aded7a15
9 changed files with 19 additions and 2 deletions

View File

@ -27,6 +27,8 @@ namespace NzbDrone.Api.Authentication
_configFileProvider = configFileProvider;
}
public int Order { get { return 10; } }
public void Register(IPipelines pipelines)
{
if (_configFileProvider.AuthenticationMethod == AuthenticationType.Forms)

View File

@ -14,6 +14,8 @@ namespace NzbDrone.Api.Extensions.Pipelines
_cacheableSpecification = cacheableSpecification;
}
public int Order { get { return 0; } }
public void Register(IPipelines pipelines)
{
pipelines.AfterRequest.AddItemToStartOfPipeline((Action<NancyContext>) Handle);

View File

@ -7,6 +7,8 @@ namespace NzbDrone.Api.Extensions.Pipelines
{
public class CorsPipeline : IRegisterNancyPipeline
{
public int Order { get { return 0; } }
public void Register(IPipelines pipelines)
{
pipelines.AfterRequest.AddItemToEndOfPipeline((Action<NancyContext>) Handle);

View File

@ -12,6 +12,8 @@ namespace NzbDrone.Api.Extensions.Pipelines
{
private readonly Logger _logger;
public int Order { get { return 0; } }
public GzipCompressionPipeline(Logger logger)
{
_logger = logger;

View File

@ -4,6 +4,8 @@ namespace NzbDrone.Api.Extensions.Pipelines
{
public interface IRegisterNancyPipeline
{
int Order { get; }
void Register(IPipelines pipelines);
}
}

View File

@ -14,6 +14,8 @@ namespace NzbDrone.Api.Extensions.Pipelines
_cacheableSpecification = cacheableSpecification;
}
public int Order { get { return 0; } }
public void Register(IPipelines pipelines)
{
pipelines.BeforeRequest.AddItemToStartOfPipeline((Func<NancyContext, Response>) Handle);

View File

@ -7,6 +7,8 @@ namespace NzbDrone.Api.Extensions.Pipelines
{
public class NzbDroneVersionPipeline : IRegisterNancyPipeline
{
public int Order { get { return 0; } }
public void Register(IPipelines pipelines)
{
pipelines.AfterRequest.AddItemToStartOfPipeline((Action<NancyContext>) Handle);

View File

@ -14,6 +14,8 @@ namespace NzbDrone.Api.Extensions.Pipelines
private static int _requestSequenceID;
public int Order { get { return 100; } }
public void Register(IPipelines pipelines)
{
pipelines.BeforeRequest.AddItemToStartOfPipeline(LogStart);

View File

@ -1,8 +1,9 @@
using System;
using NLog;
using System.Linq;
using Nancy;
using Nancy.Bootstrapper;
using Nancy.Diagnostics;
using NLog;
using NzbDrone.Api.ErrorManagement;
using NzbDrone.Api.Extensions.Pipelines;
using NzbDrone.Common.EnvironmentInfo;
@ -43,7 +44,7 @@ namespace NzbDrone.Api
private void RegisterPipelines(IPipelines pipelines)
{
var pipelineRegistrars = _tinyIoCContainer.ResolveAll<IRegisterNancyPipeline>();
var pipelineRegistrars = _tinyIoCContainer.ResolveAll<IRegisterNancyPipeline>().OrderBy(v => v.Order).ToList();
foreach (var registerNancyPipeline in pipelineRegistrars)
{