(Contentful) Webhook Server

Web Application
C#
GitHub Repository

What It Is

A web application to receive webhooks from Contentful (or something else)

Status

Last Reviewed:

I haven’t look at this in a while, but the code is solid and probably quite useful.

Details

This is a web application that serves as the target for incoming webhooks and allows you to map them to C# methods.

// This is the only thing you put in your controller action
var results = WebhookDispatcher.Process(new WebhookRequest(Request));
return Json(results);

// Then you create methods (anywhere) with attributes...
[WebhookBinding("ContentManagement.Entry.publish")]
[WebhookBinding("ContentManagement.Entry.unpublish")]
public static WebhookHandlerLogEntry DoSomething(WebhookEventArgs e)
{
  // Do stuff here
}

I put “Contentful” as a parenthetical here because, while this was written specifically for Contentful, it could pretty easily be re-used for something else. Even if you don’t use Contentful, the basic theory and logical flow are universal-ish.