(
api: Api,
extension_id: &str,
types: Option<&[&str]>,
buffering: Option<LogBuffering>,
port_number: u16,
)
| 59 | } |
| 60 | |
| 61 | pub(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)] |
no test coverage detected