public void Configuration(IAppBuilder app) { GlobalConfiguration.Configure(config => { config.DependencyResolver = new UnityDependencyResolver(UnityConfiguration.GetContainer()); ApiConfiguration.Install(config, app); }); }
public static void Install(HttpConfiguration config, IAppBuilder app) { RegisterFilterProviders(config); var container = UnityConfiguration.GetContainer(); var unityHubActivator = new UnityHubActivator(container); Microsoft.AspNet.SignalR.GlobalHost.DependencyResolver.Register(typeof(IHubActivator), () => unityHubActivator); Microsoft.AspNet.SignalR.GlobalHost.DependencyResolver.Register(typeof(IUserIdProvider), () => new UserIdProvider()); app.MapSignalR(); app.Use(typeof(TenantMiddleware)); config.Filters.Add(container.Resolve <HandleErrorAttribute>()); config.Filters.Add(container.Resolve <System.Web.Http.AuthorizeAttribute>()); app.UseCors(CorsOptions.AllowAll); config.SuppressHostPrincipal(); var mediator = container.Resolve <IMediator>(); var lazyAuthConfiguration = container.Resolve <Lazy <IAuthConfiguration> >(); config .EnableSwagger(c => c.SingleApiVersion("v1", "Slackish")) .EnableSwaggerUi(); app.UseOAuthAuthorizationServer(new OAuthOptions(lazyAuthConfiguration, mediator)); app.UseJwtBearerAuthentication(new JwtOptions(lazyAuthConfiguration)); config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType)); var jSettings = new JsonSerializerSettings(); jSettings.Formatting = Formatting.Indented; jSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; jSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); config.Formatters.Remove(config.Formatters.XmlFormatter); config.Formatters.JsonFormatter.SerializerSettings = jSettings; config.MapHttpAttributeRoutes(); }