Skip to content

Provide a better way to extract headers from a CloudEvent #178

Closed

Description

@lance

Currently, in order to extract headers from a CloudEvent, you have to first create an HTTPEmitter.

const ce = new CloudEvent({ type: 'example.event', source: 'https://example.event.source' });
const emitter = new HTTPEmitter({ url: 'http://bogus.url' });
const headers = emitter.headers();

Not ideal... you have to create a new object for no real reason. And on top of that, you have to supply it with a URL since the emitter ctor will throw without one.

Something better might be...

const { headers /* other exports such as HTTPEmitter */ } = require('cloudevents-sdk/bindings/http');
 
const ce = new CloudEvent({ type: 'example.event', source: 'https://example.event.source' });
const headers = headers(ce);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions