开源软件名称: octokit/webhooks.net开源软件地址: https://github.com/octokit/webhooks.net开源编程语言:
C#
100.0%
开源软件介绍: Octokit.Webhooks
Libraries to handle GitHub Webhooks in .NET applications.
Usage in ASP.NET Core
dotnet add package Octokit.Webhooks.AspNetCore
Create a class that derives from WebhookEventProcessor
and override any of the virtual methods to handle webhooks from GitHub. For example, to handle Pull Request webhooks:
public sealed class MyWebhookEventProcessor : WebhookEventProcessor
{
protected override Task ProcessPullRequestWebhookAsync (WebhookHeaders headers , PullRequestEvent pullRequestEvent , PullRequestAction action ) {
...
}
}
Modify your ConfigureServices()
method to register an implementation for GitHubEventProcessor
:
public void ConfigureServices (IServiceCollection services )
{
...
services .AddSingleton <WebhookEventProcessor , MyWebhookEventProcessor >();
...
}
Modify your Configure()
method to map the webhook end point:
app .UseEndpoints (endpoints =>
{
...
endpoints .MapGitHubWebhooks ();
...
});
MapGitHubWebhooks()
takes two optional parameters:
path
. Defaults to /api/github/webhooks
, the URL of the endpoint to use for GitHub.
secret
. The secret you have configured in GitHub, if you have set this up.
Thanks
License
All packages in this repository are licensed under the MIT license .
请发表评论