2013-01-29 01:07:18 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using Autofac;
|
|
|
|
|
using NLog;
|
|
|
|
|
using Nancy.Bootstrapper;
|
|
|
|
|
using Nancy.Bootstrappers.Autofac;
|
2013-01-31 02:02:13 +00:00
|
|
|
|
using NzbDrone.Services.Api.Extensions;
|
2013-01-29 01:07:18 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Services.Api
|
|
|
|
|
{
|
|
|
|
|
public class Bootstrapper : AutofacNancyBootstrapper
|
|
|
|
|
{
|
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
|
|
|
|
protected override ILifetimeScope GetApplicationContainer()
|
|
|
|
|
{
|
|
|
|
|
ApplicationPipelines.OnError.AddItemToEndOfPipeline((context, exception) =>
|
|
|
|
|
{
|
|
|
|
|
Logger.FatalException("Application Exception", exception);
|
|
|
|
|
return null;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var builder = new ContainerBuilder();
|
|
|
|
|
builder.RegisterApiServices();
|
|
|
|
|
var container = builder.Build();
|
|
|
|
|
|
|
|
|
|
return container;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override NancyInternalConfiguration InternalConfiguration
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2013-01-31 02:02:13 +00:00
|
|
|
|
return NancyInternalConfiguration.WithOverrides(c => c.Serializers.Add(typeof(NancyJsonSerializer)));
|
2013-01-29 01:07:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|