Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lance opened this issue May 21, 2020 · 0 comments · Fixed by #186
Closed

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

lance opened this issue May 21, 2020 · 0 comments · Fixed by #186
Labels
type/enhancement New feature or request

Comments

@lance
Copy link
Member

lance commented May 21, 2020

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
Labels
type/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant