[−][src]Crate cloudevents_sdk_reqwest
This crate integrates the cloudevents-sdk with reqwest to easily send and receive CloudEvents.
use cloudevents_sdk_reqwest::{RequestBuilderExt, ResponseExt}; use cloudevents::{EventBuilderV10, EventBuilder}; use serde_json::json; let client = reqwest::Client::new(); // Prepare the event to send let event_to_send = EventBuilderV10::new() .id("0001") .ty("example.test") .source("http://localhost/") .data("application/json", json!({"hello": "world"})) .build()?; // Send request let response = client.post("http://localhost") .event(event_to_send)? .send().await?; // Parse response as event let received_event = response .into_event().await?;
Check out the cloudevents-sdk docs for more details on how to use cloudevents::Event
.
Structs
RequestSerializer | Wrapper for |
ResponseDeserializer | Wrapper for |
Traits
RequestBuilderExt | Extension Trait for |
ResponseExt | Extension Trait for |
Functions
event_to_request | Method to fill a |
response_to_event |