/// <summary> /// Configures a Microsoft Azure Table Storage implementation of <see cref="IWebHookStore"/> /// which provides a persistent store for registered WebHooks used by the custom WebHooks module. /// </summary> /// <param name="config">The current <see cref="HttpConfiguration"/>config.</param> public static void InitializeCustomWebHooksAzureQueueSender(this HttpConfiguration config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } ILogger logger = config.DependencyResolver.GetLogger(); SettingsDictionary settings = config.DependencyResolver.GetSettings(); IStorageManager storageManager = StorageManager.GetInstance(logger); IWebHookSender sender = new AzureWebHookSender(storageManager, settings, logger); CustomServices.SetSender(sender); }
/// <summary> /// /// </summary> /// <param name="config"></param> public static void InitializeAuthenticatedWebHooksSender(this HttpConfiguration config) { if (config == null) { throw new ArgumentNullException("config"); } WebHooksConfig.Initialize(config); ILogger logger = config.DependencyResolver.GetLogger(); HttpClient client = config.DependencyResolver.GetService <HttpClient>(); // setting the custom sender IWebHookSender sender = new AuthorizedWebHookSender(logger, client); CustomServices.SetSender(sender); }
public static void Register(HttpConfiguration config) { // Web API configuration and services var controllerType = typeof(WebHookReceiversController); // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); // Load Azure Storage or SQL for persisting subscriptions // config.InitializeCustomWebHooksAzureStorage(); // config.InitializeCustomWebHooksSqlStorage(); // Load Azure Queued Sender for enqueueing outgoing WebHooks to an Azure Storage Queue // config.InitializeCustomWebHooksAzureQueueSender(); // Uncomment the following to set a custom WebHook sender where you can control how you want // the outgoing WebHook request to look. ILogger logger = CommonServices.GetLogger(); IWebHookSender sender = new TestWebhookSender(logger); CustomServices.SetSender(sender); // Load basic support for sending WebHooks config.InitializeCustomWebHooks(); // Load Web API controllers for managing subscriptions config.InitializeCustomWebHooksApis(); config.InitializeReceiveCustomWebHooks(); config.EnsureInitialized(); var webhookRoutes = config.Routes; config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/octet-stream")); }