RagingKore / Krimson

MIT License
11 stars 4 forks source link

Add webhook capability to Krimson #6

Closed jchannon closed 2 years ago

jchannon commented 2 years ago

This tidies some dependencies up and deletes the PushConnector.

It introduces a Connector.Http project that has a IWebhookHandler that exposes two methods to handle verification of the payload and to get the data.

The implementation of the webhooks maps a path to a POST request and then executes the IWebhookhandler methods and then passes the data in KrimsonProducer.

I tried to minimise dependencies and we could possible minimise some more and move the interface and extensions into Krimson.Connectors itself.

One thing to note is that this only supports one registration of a HTTP route and IWebhookHandler registration. I did start to look at the DI fun with multiple implementations of the interface but figured we'll cross that bridge if we need to.

I've added an example project but the API looks like:

var builder = WebApplication.CreateBuilder(args);

builder.UseKrimson()
    .AddReader(rdr => rdr.ClientId(builder.Configuration["Application:Name"]))
    .AddProducer(
        pdr => pdr
            .ClientId(builder.Configuration["Application:Name"])
            .Topic("foo.bar.baz")
    )
    .AddWebhookHandler<WebhookHandler>();

var app = builder.Build();

app.AddWebhookConnector("/mywebhook");

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

app.Run();
RagingKore commented 2 years ago

As agreed, will apply some of those changes and merge it :)

jchannon commented 2 years ago

This commit will be worth millions I tell you!

On Fri, 29 Jul 2022 at 18:46, Sérgio Silveira @.***> wrote:

As agreed, will apply some of those changes and merge it :)

— Reply to this email directly, view it on GitHub https://github.com/RagingKore/Krimson/pull/6#issuecomment-1199797903, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAZVJVQ265MHS3GUXQ7JCDVWQKI7ANCNFSM545MOVVA . You are receiving this because you authored the thread.Message ID: @.***>

RagingKore commented 2 years ago

specially now lol