Skip to content

Commit 063bf1e

Browse files
authored
Merge pull request #3 from streamfold/fix-reg-name
Fix register name to match binary name
2 parents da7ef77 + ebf3db8 commit 063bf1e

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

src/lambda/api.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub async fn register(
2424
.method(Method::POST)
2525
.uri(&url)
2626
// This value must match the binary name, or this call will 403
27-
.header(constants::EXTENSION_NAME_HEADER, "rotel-lambda-extension")
27+
.header(constants::EXTENSION_NAME_HEADER, "rotel-extension")
2828
.header(
2929
constants::EXTENSION_ACCEPT_FEATURE,
3030
constants::EXTENSION_FEATURE_ACCOUNTID,
@@ -33,17 +33,24 @@ pub async fn register(
3333
.body(Full::from(Bytes::from(serde_json::to_vec(&events)?)))?;
3434

3535
let resp = client.request(req).await?;
36-
if resp.status() != 200 {
36+
let (parts, body) = resp.into_parts();
37+
let status = parts.status;
38+
39+
if status != 200 {
40+
let text = body
41+
.collect()
42+
.await
43+
.map_err(|e| format!("Failed to read response body from {}: {}", url, e))
44+
.map(|c| c.to_bytes())
45+
.map(|s| String::from_utf8(s.to_vec()))?
46+
.map_err(|e| format!("Unable to convert response body to string: {}", e))?;
3747
return Err(format!(
38-
"Can not register extension at {}, got {}",
39-
url,
40-
resp.status()
48+
"Can not register extension at {}, got {}: {}",
49+
url, status, text,
4150
)
4251
.into());
4352
}
4453

45-
let (parts, body) = resp.into_parts();
46-
4754
let ext_id = match parts.headers.get(constants::EXTENSION_ID_HEADER) {
4855
None => {
4956
return Err("Can not get extension id, got no header".into());

0 commit comments

Comments
 (0)