Skip to content

Build status Coveralls branch NuGet

LSL.HttpMessageHandlers.Capturing.Core

Provides a message handler as the basis for capturing requests and responses.

Quick Start

The following example uses the provided DelegatingAsyncRequestAndResponseCapturer (it assumes an IServiceCollection for services):

var capturedUrls = new List<string>();

services
    .AddHttpClient<MyTestClient>()
    .AddRequestAndResponseCapturing(c => c
        .AddCapturingHandlerFactory(serviceProvider => 
            new DelegatingAsyncRequestAndResponseCapturer(c =>
            {
                capturedUrls.Add(c.Request.RequestUri.ToString());
                return Task.CompletedTask;
            }))
    );

// when the client is used then all request URIs will be captured in capturedUrls