Closed
Description
Describe the Bug
The HTTP Emitter should have static methods such that we don't need to construct multiple Emitters before sending our CE.
Currently we must instantiate the Emitter with a URL and then emit. See README.
const { CloudEvent, Emitter } = require("cloudevents");
const ce = new CloudEvent({ type, source, data });
async function test() {
const emitter = new Emitter({
url: "https://cloudevents.io/example"
});
await emitter.send(ce);
}
Expected Behavior
Like the static Receiver.accept(...)
, I'd imagine an Emitter.send(...)
.
const { CloudEvent, Emitter } = require("cloudevents");
const ce = new CloudEvent({ type, source, data });
async function test() {
await Emitter.send(ce, "https://cloudevents.io/example");
}
This format is more idiomatic and is similar to the format for what other npm modules do:
http
Standard library – (http.request(url, options)
)axios
- (axios.post(url, options)
)request
- (request.post({ url, ...options })
)superagent
- (superagent.post(url).send(body).end((err, res) => {})
)
Metadata
Metadata
Assignees
Labels
No labels