You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.4 KiB
1.4 KiB
LINGYUN.Abp.Webhooks
Webhook基础模块,提供Webhook的基本定义和功能。
功能特性
- 基本Webhook定义
- Webhook发布和订阅
- Webhook事件数据处理
- Webhook配置管理
模块引用
[DependsOn(typeof(AbpWebhooksModule))]
public class YouProjectModule : AbpModule
{
// other
}
基本用法
- 定义Webhook
public class YourWebhookDefinitionProvider : WebhookDefinitionProvider
{
public override void Define(IWebhookDefinitionContext context)
{
context.Add(
new WebhookDefinition(
name: "YourWebhook",
displayName: L("DisplayName:YourWebhook"),
description: L("Description:YourWebhook")
)
);
}
}
- 发布Webhook
public class YourService
{
private readonly IWebhookPublisher _webhookPublisher;
public YourService(IWebhookPublisher webhookPublisher)
{
_webhookPublisher = webhookPublisher;
}
public async Task PublishWebhook()
{
await _webhookPublisher.PublishAsync(
webhookName: "YourWebhook",
data: new { /* webhook data */ }
);
}
}
- 处理Webhook事件
public class YourWebhookHandler : IWebhookHandler, ITransientDependency
{
public async Task HandleWebhookAsync(WebhookPayload webhook)
{
// 处理webhook事件
}
}