コード例 #1
0
        /// <summary>
        /// Compares the request to available handlers, executes matches, and returns log entires
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static List <WebhookHandlerLogEntry> Process(WebhookRequest request)
        {
            var log = new List <WebhookHandlerLogEntry>();
            var e   = new WebhookEventArgs(request);

            foreach (var handler in Handlers.Where(x => x.IsMatch(request)))
            {
                e.ActiveHandler = handler;  // This will change each time through...

                var result = handler.Handler(e);

                if (result != null)
                {
                    result.Source = result.Source ?? handler.Name; // If they don't explicitly set a source, use the handler name
                    log.Add(result);
                }
            }

            return(log);
        }
コード例 #2
0
        public bool IsMatch(WebhookRequest request)
        {
            var matchesTopic = true;
            var matchesName  = true;

            if (ForTopic != null && ForTopic != "*")
            {
                if (ForTopic != request.ContentfulTopic)
                {
                    matchesTopic = false;
                }
            }

            if (ForName != null && ForName != "*")
            {
                if (ForName != request.ContentfulWebhookName)
                {
                    matchesName = false;
                }
            }

            return(matchesTopic && matchesName);
        }
コード例 #3
0
 public WebhookEventArgs(WebhookRequest request)
 {
     Request = request;
 }