MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / post_event

Method post_event

chirpstack/src/integration/blynk.rs:130–156  ·  view source on GitHub ↗
(&self, event: &str, pl: &T)

Source from the content-addressed store, hash-verified

128 }
129
130 async fn post_event<T>(&self, event: &str, pl: &T) -> Result<()>
131 where
132 T: ?Sized + Serialize,
133 {
134 let (integration_url, integration_token) = self.parse_token()?;
135 let b = serde_json::to_vec(pl)?;
136
137 info!(event = %event, url = %integration_url, "Posting event");
138
139 let mut headers = HeaderMap::new();
140 headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
141 headers.insert(
142 AUTHORIZATION,
143 format!("Bearer {}", integration_token).parse().unwrap(),
144 );
145
146 get_client()
147 .post(&integration_url)
148 .body(b.to_vec())
149 .query(&[("event", event)])
150 .headers(headers)
151 .send()
152 .await?
153 .error_for_status()?;
154
155 Ok(())
156 }
157}
158
159#[async_trait]

Callers 2

uplink_eventMethod · 0.45
join_eventMethod · 0.45

Calls 6

parse_tokenMethod · 0.80
insertMethod · 0.80
unwrapMethod · 0.80
postMethod · 0.80
get_clientFunction · 0.70
to_vecMethod · 0.45

Tested by

no test coverage detected