poppastring / dasblog-core

The original DasBlog reimagined with ASP.NET Core
MIT License
469 stars 193 forks source link

CloudEvents support #673

Open clemensv opened 1 year ago

clemensv commented 1 year ago

do-not-merge

This PR adds CloudEvents support addressing #671.

I had to move the cheese a bit in the RSS feed area, though, because I need an endpoint for an event consumer to fetch the full content from. I'm assuming that we can't route the entire text of all posts through the eventing channel.

Base feed still at ./feed/rss

In config, you enable the CloudEvents support with

 <EnableCloudEvents>false</EnableCloudEvents>

and you need to add one or more HTTPS target endpoints to deliver those events to. That is currently done synchronously, inline with posting the item, but should be very fast with an event broker.

The targets are configured with a <CloudEventsTargets> element that can hold one or more targets. The Uri holds the target Uri, the Headers collection holds name/value pairs for HTTP headers to add to the request. Here, I show an Event Grid SAS key header.

<CloudEventsTargets>
      <CloudEventsTarget>
        <ProfileName>eventGrid</ProfileName>
        <Uri>https://{myns}.westeurope-1.eventgrid.azure.net/api/events</Uri>
        <Headers>
          <Header>
            <Name>aeg-sas-key</Name>
            <Value>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</Value>
          </Header>
        </Headers>
      </CloudEventsTarget>
  </CloudEventsTargets>
poppastring commented 1 year ago

@clemensv I am holding off on this until you give me the all clear for another review.