public static void Register(HttpConfiguration config, ScriptSettingsManager settingsManager = null, WebHostSettings settings = null, Action <ContainerBuilder, WebHostSettings> dependencyCallback = null) { if (config == null) { throw new ArgumentNullException("config"); } settingsManager = settingsManager ?? ScriptSettingsManager.Instance; settings = settings ?? WebHostSettings.CreateDefault(settingsManager); var builder = new ContainerBuilder(); builder.RegisterApiControllers(typeof(FunctionsController).Assembly); AutofacBootstrap.Initialize(settingsManager, builder, settings); // Invoke registration callback dependencyCallback?.Invoke(builder, settings); var container = builder.Build(); config.DependencyResolver = new AutofacWebApiDependencyResolver(container); config.Formatters.Add(new PlaintextMediaTypeFormatter()); config.Services.Replace(typeof(IExceptionHandler), new ExceptionProcessingHandler(config)); AddMessageHandlers(config); // Web API configuration and services // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "Home", routeTemplate: string.Empty, defaults: new { controller = "Home" }); config.Routes.MapHttpRoute( name: "Functions", routeTemplate: "{*uri}", defaults: new { controller = "Functions" }); // Initialize WebHook Receivers config.InitializeReceiveGenericJsonWebHooks(); config.InitializeReceiveAzureAlertWebHooks(); config.InitializeReceiveKuduWebHooks(); config.InitializeReceivePusherWebHooks(); config.InitializeReceiveStripeWebHooks(); config.InitializeReceiveTrelloWebHooks(); config.InitializeReceiveDynamicsCrmWebHooks(); config.InitializeReceiveMailChimpWebHooks(); config.InitializeReceiveSlackWebHooks(); config.InitializeReceiveBitbucketWebHooks(); config.InitializeReceiveDropboxWebHooks(); config.InitializeReceiveWordPressWebHooks(); config.InitializeReceiveGitHubWebHooks(); config.InitializeReceiveSalesforceWebHooks(); }
public static void Register(HttpConfiguration config, WebHostSettings settings = null) { if (config == null) { throw new ArgumentNullException("config"); } if (settings == null) { throw new ArgumentNullException("settings"); } // Delete hostingstart.html if any. Azure creates that in all sites by default string hostingStart = Path.Combine(settings.ScriptPath, "hostingstart.html"); if (File.Exists(hostingStart)) { File.Delete(hostingStart); } // Add necessary folders to the %PATH% PrependFoldersToEnvironmentPath(); var builder = new ContainerBuilder(); builder.RegisterApiControllers(typeof(FunctionsController).Assembly); AutofacBootstrap.Initialize(builder, settings); var container = builder.Build(); config.DependencyResolver = new AutofacWebApiDependencyResolver(container); config.MessageHandlers.Add(new EnsureHostRunningHandler(config)); // Web API configuration and services // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "Home", routeTemplate: string.Empty, defaults: new { controller = "Home" }); config.Routes.MapHttpRoute( name: "Functions", routeTemplate: "{*uri}", defaults: new { controller = "Functions" }); // Initialize WebHook Receivers config.InitializeReceiveGenericJsonWebHooks(); config.InitializeReceiveAzureAlertWebHooks(); config.InitializeReceiveKuduWebHooks(); config.InitializeReceivePusherWebHooks(); config.InitializeReceiveStripeWebHooks(); config.InitializeReceiveTrelloWebHooks(); config.InitializeReceiveDynamicsCrmWebHooks(); config.InitializeReceiveMailChimpWebHooks(); config.InitializeReceiveSlackWebHooks(); config.InitializeReceiveBitbucketWebHooks(); config.InitializeReceiveDropboxWebHooks(); config.InitializeReceiveWordPressWebHooks(); config.InitializeReceiveGitHubWebHooks(); config.InitializeReceiveSalesforceWebHooks(); }