< Summary

Information
Class: TeleFlow.Telegram.Webhooks.TelegramWebhookEndpointRouteBuilderExtensions
Assembly: TeleFlow.Framework.Webhooks
File(s): /_/src/TeleFlow.Framework.Webhooks/TelegramWebhookEndpointRouteBuilderExtensions.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 30
Line coverage: 100%
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
MapTelegramWebhook(...)100%11100%

File(s)

/_/src/TeleFlow.Framework.Webhooks/TelegramWebhookEndpointRouteBuilderExtensions.cs

#LineLine coverage
 1using Microsoft.AspNetCore.Builder;
 2using Microsoft.AspNetCore.Http;
 3using Microsoft.AspNetCore.Routing;
 4using Microsoft.Extensions.DependencyInjection;
 5using TeleFlow.Framework.Application;
 6using TeleFlow.Framework.Updates;
 7
 8namespace TeleFlow.Telegram.Webhooks;
 9
 10public static class TelegramWebhookEndpointRouteBuilderExtensions
 11{
 12    public static RouteHandlerBuilder MapTelegramWebhook(this IEndpointRouteBuilder endpoints)
 13    {
 1014        ArgumentNullException.ThrowIfNull(endpoints);
 15
 1016        var options = endpoints.ServiceProvider.GetRequiredService<TelegramWebhookOptions>();
 1017        var processor = endpoints.ServiceProvider.GetRequiredService<IUpdateProcessor>();
 18
 1019        TeleFlowRuntimeValidatorRunner.Validate(endpoints.ServiceProvider);
 20
 921        return endpoints.MapTelegramWebhook(
 922            options.Path,
 923            async (update, _, cancellationToken) =>
 924            {
 625                await processor.ProcessAsync(new TelegramUpdatePayload(update), cancellationToken).ConfigureAwait(false)
 526                return Results.Ok();
 527            },
 1828            rawOptions => rawOptions.SecretToken = options.SecretToken);
 29    }
 30}