(ag: ApiGatewayWebsocketProxyRequest)
| 297 | |
| 298 | #[cfg(feature = "apigw_websockets")] |
| 299 | fn into_websocket_request(ag: ApiGatewayWebsocketProxyRequest) -> http::Request<Body> { |
| 300 | let http_method = ag.http_method; |
| 301 | let host = ag |
| 302 | .headers |
| 303 | .get(http::header::HOST) |
| 304 | .and_then(|s| s.to_str().ok()) |
| 305 | .or(ag.request_context.domain_name.as_deref()); |
| 306 | let raw_path = ag.path.unwrap_or_default(); |
| 307 | let path = apigw_path_with_stage(&ag.request_context.stage, &raw_path); |
| 308 | |
| 309 | let builder = http::Request::builder() |
| 310 | .uri(build_request_uri( |
| 311 | &path, |
| 312 | &ag.headers, |
| 313 | host, |
| 314 | Some((&ag.multi_value_query_string_parameters, &ag.query_string_parameters)), |
| 315 | )) |
| 316 | .extension(RawHttpPath(raw_path)) |
| 317 | // multi-valued query string parameters are always a super |
| 318 | // set of singly valued query string parameters, |
| 319 | // when present, multi-valued query string parameters are preferred |
| 320 | .extension(QueryStringParameters( |
| 321 | if ag.multi_value_query_string_parameters.is_empty() { |
| 322 | ag.query_string_parameters |
| 323 | } else { |
| 324 | ag.multi_value_query_string_parameters |
| 325 | }, |
| 326 | )) |
| 327 | .extension(PathParameters(QueryMap::from(ag.path_parameters))) |
| 328 | .extension(StageVariables(QueryMap::from(ag.stage_variables))) |
| 329 | .extension(RequestContext::WebSocket(ag.request_context)); |
| 330 | |
| 331 | // merge headers into multi_value_headers and make |
| 332 | // multi-value_headers our canonical source of request headers |
| 333 | let mut headers = ag.multi_value_headers; |
| 334 | headers.extend(ag.headers); |
| 335 | |
| 336 | let base64 = ag.is_base64_encoded; |
| 337 | let mut req = builder |
| 338 | .body( |
| 339 | ag.body |
| 340 | .as_deref() |
| 341 | .map_or_else(Body::default, |b| Body::from_maybe_encoded(base64, b)), |
| 342 | ) |
| 343 | .expect("failed to build request"); |
| 344 | |
| 345 | // no builder method that sets headers in batch |
| 346 | let _ = std::mem::replace(req.headers_mut(), headers); |
| 347 | let _ = std::mem::replace(req.method_mut(), http_method.unwrap_or(http::Method::GET)); |
| 348 | |
| 349 | req |
| 350 | } |
| 351 | |
| 352 | #[cfg(feature = "vpc_lattice")] |
| 353 | fn into_vpc_lattice_request(vlr: VpcLatticeRequestV2) -> http::Request<Body> { |
no test coverage detected