2013-05-05 00:09:25 +03:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Nancy.Bootstrapper;
|
|
|
|
using Nancy.Owin;
|
|
|
|
using Owin;
|
|
|
|
|
2013-08-07 08:32:22 +03:00
|
|
|
namespace NzbDrone.Host.Owin.MiddleWare
|
2013-05-05 00:09:25 +03:00
|
|
|
{
|
|
|
|
public class NancyMiddleWare : IOwinMiddleWare
|
|
|
|
{
|
|
|
|
private readonly INancyBootstrapper _nancyBootstrapper;
|
|
|
|
|
|
|
|
public NancyMiddleWare(INancyBootstrapper nancyBootstrapper)
|
|
|
|
{
|
|
|
|
_nancyBootstrapper = nancyBootstrapper;
|
|
|
|
}
|
|
|
|
|
2013-05-06 00:24:33 +03:00
|
|
|
public int Order { get { return 1; } }
|
|
|
|
|
2013-05-05 00:09:25 +03:00
|
|
|
public void Attach(IAppBuilder appBuilder)
|
|
|
|
{
|
2013-08-20 04:45:19 +03:00
|
|
|
var nancyOwinHost = new NancyOwinHost(null, _nancyBootstrapper, new HostConfiguration());
|
2013-05-05 00:09:25 +03:00
|
|
|
appBuilder.Use((Func<Func<IDictionary<string, object>, Task>, Func<IDictionary<string, object>, Task>>)(next => (Func<IDictionary<string, object>, Task>)nancyOwinHost.Invoke), new object[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|