Packs the body and headers of a webhook request into as many rows as necessary. TODO(parkmycar): Should we be consolidating the returned Rows here? Presumably something in storage would already be doing it, so no need to do it twice?
(
body: &[u8],
body_format: &WebhookBodyFormat,
headers: &BTreeMap<String, String>,
header_tys: &WebhookHeaders,
)
| 185 | /// TODO(parkmycar): Should we be consolidating the returned Rows here? Presumably something in |
| 186 | /// storage would already be doing it, so no need to do it twice? |
| 187 | fn pack_rows( |
| 188 | body: &[u8], |
| 189 | body_format: &WebhookBodyFormat, |
| 190 | headers: &BTreeMap<String, String>, |
| 191 | header_tys: &WebhookHeaders, |
| 192 | ) -> Result<Vec<(Row, Diff)>, AppendWebhookError> { |
| 193 | // This method isn't that "deep" but it reflects the way we intend for the packing process to |
| 194 | // work and makes testing easier. |
| 195 | let rows = transform_body(body, body_format)? |
| 196 | .into_iter() |
| 197 | .map(|row| pack_header(row, headers, header_tys).map(|row| (row, Diff::ONE))) |
| 198 | .collect::<Result<_, _>>()?; |
| 199 | Ok(rows) |
| 200 | } |
| 201 | |
| 202 | /// Transforms the body of a webhook request into a `Vec<BodyRow>`. |
| 203 | fn transform_body( |