Nera.Lib.Webhook
1.0.1
dotnet add package Nera.Lib.Webhook --version 1.0.1
NuGet\Install-Package Nera.Lib.Webhook -Version 1.0.1
<PackageReference Include="Nera.Lib.Webhook" Version="1.0.1" />
<PackageVersion Include="Nera.Lib.Webhook" Version="1.0.1" />
<PackageReference Include="Nera.Lib.Webhook" />
paket add Nera.Lib.Webhook --version 1.0.1
#r "nuget: Nera.Lib.Webhook, 1.0.1"
#:package Nera.Lib.Webhook@1.0.1
#addin nuget:?package=Nera.Lib.Webhook&version=1.0.1
#tool nuget:?package=Nera.Lib.Webhook&version=1.0.1
Nera.Lib.Webhook
A comprehensive webhook handling library for .NET applications, providing webhook reception, processing, and management capabilities with priority-based processing and background job support.
Features
- Webhook Reception: Receive and validate incoming webhook requests
- Priority Processing: Support for High/Normal/Low priority webhooks
- Background Processing: Quartz.NET integration for background job processing
- Database Storage: Entity Framework Core integration with PostgreSQL support
- Retry Logic: Automatic retry with exponential backoff for failed webhooks
- Event Publishing: Integration events for webhook lifecycle
- Auto Migration: Automatic database schema migration
- Comprehensive APIs: Full CRUD operations and statistics
Quick Start
1. Install the Package
<PackageReference Include="Nera.Lib.Webhook" Version="1.0.0" />
2. Configure Services
// In Program.cs or Startup.cs
builder.Services
.AddWebhookServices(builder.Configuration)
.AddWebhookDbContext(connectionString);
3. Create Webhook Endpoint
[ApiController]
[Route("api/webhooks")]
public class WebhookController : ControllerBase
{
private readonly IWebhookReceiver _webhookReceiver;
public WebhookController(IWebhookReceiver webhookReceiver)
{
_webhookReceiver = webhookReceiver;
}
[HttpPost("receive")]
public async Task<IActionResult> ReceiveWebhook(
[FromHeader(Name = "X-Event-Type")] string eventType,
[FromHeader(Name = "X-Priority")] string? priority = null)
{
var webhookId = await _webhookReceiver.ReceiveWebhookAsync(
Request,
eventType,
"your-source",
priority != null && Enum.TryParse<WebhookPriority>(priority, true, out var p) ? p : WebhookPriority.Normal);
return Ok(new { WebhookId = webhookId });
}
}
4. Configure Database
// Connection string should point to your database
var connectionString = "Host=localhost;Port=5432;Database=yourdb;Username=user;Password=pass";
Configuration
Webhook Options
{
"Webhook": {
"DefaultPriority": "Normal",
"MaxRetryAttempts": 3,
"RetryIntervalMinutes": 5,
"SignatureHeaderName": "X-Hub-Signature",
"EnableAutoMigration": true
}
}
Environment Variables
ENV_CONNECTION_STRING=Host=localhost;Port=5432;Database=webhookdb;Username=user;Password=pass
Priority System
- High/Critical: Processed immediately upon receipt
- Normal: Queued for background processing
- Low: Queued for background processing with lower priority
Database Schema
The library creates a webhook schema with the following table:
WebhookEvents: Stores all webhook events with processing status, retry information, and metadata
API Endpoints
The library provides comprehensive APIs for webhook management:
GET /api/webhooks/{id}- Get webhook detailsGET /api/webhooks- List webhooks with filteringGET /api/webhooks/statistics- Get webhook statisticsPOST /api/webhooks/{id}/retry- Retry failed webhook
Integration Events
The library publishes the following integration events:
WebhookReceivedEvent: When a webhook is receivedWebhookProcessedEvent: When a webhook is processed (success or failure)
Background Processing
Webhooks are processed by Quartz.NET jobs that run every 30 seconds by default. You can configure the schedule in the WebhookQuartzConfiguration.
Error Handling
- Automatic retry with exponential backoff
- Dead letter queue for permanently failed webhooks
- Comprehensive error logging
- Status tracking for all webhook events
Examples
See the Example.Webhook project for complete implementation examples.
License
MIT License - see LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.EntityFrameworkCore (>= 9.0.9)
- Microsoft.EntityFrameworkCore.Design (>= 9.0.9)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.9)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.9)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.9)
- Microsoft.Extensions.Options (>= 9.0.9)
- Nera.Lib.Core (>= 1.0.14)
- Nera.Lib.Database (>= 1.0.10)
- Newtonsoft.Json (>= 13.0.4)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 9.0.4)
- Quartz (>= 3.8.0)
- Quartz.Extensions.Hosting (>= 3.8.0)
- System.Text.Json (>= 9.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.