MCPcopy Index your code
hub / github.com/aws/aws-lambda-rust-runtime / subscribe_request

Function subscribe_request

lambda-extension/src/requests.rs:61–88  ·  view source on GitHub ↗
(
    api: Api,
    extension_id: &str,
    types: Option<&[&str]>,
    buffering: Option<LogBuffering>,
    port_number: u16,
)

Source from the content-addressed store, hash-verified

59}
60
61pub(crate) fn subscribe_request(
62 api: Api,
63 extension_id: &str,
64 types: Option<&[&str]>,
65 buffering: Option<LogBuffering>,
66 port_number: u16,
67) -> Result<Request<Body>, Error> {
68 let types = types.unwrap_or(&["platform", "function"]);
69
70 let data = serde_json::json!({
71 "schemaVersion": api.schema_version(),
72 "types": types,
73 "buffering": buffering.unwrap_or_default(),
74 "destination": {
75 "protocol": "HTTP",
76 "URI": format!("http://sandbox.localdomain:{port_number}"),
77 }
78 });
79
80 let req = build_request()
81 .method(Method::PUT)
82 .uri(api.uri())
83 .header(EXTENSION_ID_HEADER, extension_id)
84 .header(CONTENT_TYPE_HEADER_NAME, CONTENT_TYPE_HEADER_VALUE)
85 .body(Body::from(serde_json::to_string(&data)?))?;
86
87 Ok(req)
88}
89
90/// Payload to send error information to the Extensions API.
91#[derive(Debug, Serialize)]

Callers 1

registerMethod · 0.85

Calls 2

build_requestFunction · 0.85
uriMethod · 0.80

Tested by

no test coverage detected