Open oasisk opened 1 year ago
Hi @oasisk
The SDK supports sending events. Is your question how to send an event to an HTTP endpoint? Are you looking for a browser-based solution (so with a WebAssembly)? And how should the event be encoded (e.g. JSON)?
@Lazzaretti ..yes..want to understand how do we send events to http end point?
This thread is very old, and I presume moot, but here is a simple example: maybe we could close this issue?
// [dependencies]
// cloudevents-sdk = {version = "0.7", features = ["reqwest"]}
// reqwest = "0.11"
// tokio = {version = "1.41", features = ["rt-multi-thread", "macros"]}
use cloudevents::{binding::reqwest::RequestBuilderExt, Data, EventBuilder, EventBuilderV10};
#[tokio::main]
async fn main() {
let ce = EventBuilderV10::new()
.id("id-1")
.source("source")
.ty("type")
.data("text/plain", Data::String("data".to_owned()))
.build()
.unwrap();
let url = "https://httpbin.org/post";
reqwest::Client::new()
.post(url)
.event(ce)
.unwrap()
.send()
.await
.unwrap();
}
Javascript sdk supports sending events , how to send events using rust sdk.
https://github.com/cloudevents/sdk-javascript#emitting-events