Пример #1
0
        public async Task InvokeAsync(HttpContext context)
        {
            var request = new WebhooksRequestForAspNetCore(context);
            var isRequestManagedByTweetinvi = await _accountActivityHandler.IsRequestManagedByTweetinviAsync(request).ConfigureAwait(false);

            if (isRequestManagedByTweetinvi)
            {
                var routeHandled = await _accountActivityHandler.TryRouteRequestAsync(request).ConfigureAwait(false);

                if (routeHandled)
                {
                    return;
                }
            }

            // Continue to any other request supported by the website.
            await _next(context).ConfigureAwait(false);
        }
Пример #2
0
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var requestHandler = new WebhooksRequestHandlerForWebApi(request);

            if (await _accountActivityRequestHandler.IsRequestManagedByTweetinviAsync(requestHandler).ConfigureAwait(false))
            {
                var routeHandled = await _accountActivityRequestHandler.TryRouteRequestAsync(requestHandler).ConfigureAwait(false);

                if (routeHandled)
                {
                    var response = requestHandler.GetHttpResponseMessage();

                    var tsc = new TaskCompletionSource <HttpResponseMessage>();
                    tsc.SetResult(response);

                    return(await tsc.Task.ConfigureAwait(false));
                }
            }

            return(await base.SendAsync(request, cancellationToken).ConfigureAwait(false));
        }