Library to make consuming SocketLabs webhooks easier.
- Visual Studio or VSCode
- .NET 8
Import using dotnet CLI or the Package Manager console in Visual Studio
dotnet add package SocketLabs.EventWebhooks.Extensions
Install-Package SocketLabs.EventWebhooks.Extensions
var builder = WebApplication.CreateBuilder(args);
// Code removed for brevity ...
// Add the webhook endpoints
builder.Services.AddWebhookEndpoints(builder.Configuration);
// Add custom implementation of IWebhookEventHandler
builder.Services.AddSingleton<IWebhookEventHandler, WebhookEventHandler>();
Note
Name
can be any string. We've chosen a Guid
for this example. The name is used in the endpoint URL you will configure in the portal.
{
"WebhookOptions": {
"WebhookEndpoints": [
{
"Name": "cc0b4dc6-d867-49f5-9d8e-8357997789af",
"SecretKey": "Z123456AbcD1234563Ef"
}
]
}
}
https://example.com/api/v1/webhookevents/cc0b4dc6-d867-49f5-9d8e-8357997789af
Important
Kestrel's default MaxRequestBodySize
is 28.6MB which is smaller then our maximum email message of 50MB
var builder = WebApplication.CreateBuilder(args);
// Code removed for brevity ...
// Add the webhook endpoints
builder.Services.AddInboundParseEndpoints(builder.Configuration);
// Add custom implementation of IParsedMessagesEventHandler
builder.Services.AddSingleton<IParsedMessagesEventHandler, ParsedMessageEventHandler>();
// Increase the max body size.
builder.WebHost.ConfigureKestrel(options =>
{
options.Limits.MaxRequestBodySize = 50 * 1024 * 1024; //50Mib
});
{
"InboundOptions": {
"InboundEndpoints": [
{
"Name": "8c49fad7-7897-4cc7-bbd5-5c26d29dcb7b",
"SecretKey": "Z123456AbcD1234563Ef"
}
]
}
}
https://example.com/api/v1/parsedmessages/8c49fad7-7897-4cc7-bbd5-5c26d29dcb7b
- 1.0.0 Initial Release