Skip to content

Conversation

@null8626
Copy link
Member

The following pull request is a toned down version of #29. This pull request focuses solely on adding a webhooks wrapper for ASP.NET Core/Blazor.

@velddev
Copy link
Contributor

velddev commented Sep 17, 2025

This is not how a ASP.NET Core webhook endpoint should look like. Prefer using the minimal API to create a route at build-time. This will let the internal ASP.NET core router handle all of the actual context.

public static class RoutingExtension {
  public static void UseVoteWebhook(IRouteEndpointBuilder router, string path, ...) {
    router.MapGet(path, (req) => {
      ...
    });  
  }
}

@null8626
Copy link
Member Author

Will work on it.

@null8626
Copy link
Member Author

Done. Made it more similar to Node.js SDK' webhooks wrapper.

Example usage:

using DiscordBotsList.Api.Webhooks;

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/", () => "Hello World!");

var webhooks = new Webhooks("my webhook secret");

app.MapPost("/webhooks", webhooks.Listener((context, vote) =>
{
    Console.WriteLine($"A user with the ID of {vote.VoterId} has voted us on Top.gg!");

    return Task.CompletedTask;
}));

app.Run();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants