< Summary

Information
Class: Elsa.Api.Client.HttpMessageHandlers.ApiKeyHttpMessageHandler
Assembly: Elsa.Api.Client
File(s): /home/runner/work/elsa-core/elsa-core/src/clients/Elsa.Api.Client/HttpMessageHandlers/ApiKeyHttpMessageHandler.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 7
Coverable lines: 7
Total lines: 30
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
SendAsync()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/clients/Elsa.Api.Client/HttpMessageHandlers/ApiKeyHttpMessageHandler.cs

#LineLine coverage
 1using System.Net.Http.Headers;
 2using Elsa.Api.Client.Options;
 3using Microsoft.Extensions.Options;
 4
 5namespace Elsa.Api.Client.HttpMessageHandlers;
 6
 7/// <summary>
 8/// An <see cref="HttpMessageHandler"/> that configures the outgoing HTTP request to use an API key as the authorization
 9/// </summary>
 10public class ApiKeyHttpMessageHandler : DelegatingHandler
 11{
 12    private readonly ElsaClientOptions _options;
 13
 14    /// <summary>
 15    /// Initializes a new instance of the <see cref="ApiKeyHttpMessageHandler"/> class.
 16    /// </summary>
 017    public ApiKeyHttpMessageHandler(IOptions<ElsaClientOptions> options)
 18    {
 019        _options = options.Value;
 020    }
 21
 22    /// <inheritdoc />
 23    protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellat
 24    {
 025        var apiKey = _options.ApiKey;
 026        request.Headers.Authorization = new AuthenticationHeaderValue("ApiKey", apiKey);
 27
 028        return await base.SendAsync(request, cancellationToken);
 029    }
 30}