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

Function into_proxy_request

lambda-http/src/request.rs:185–236  ·  view source on GitHub ↗
(ag: ApiGatewayProxyRequest)

Source from the content-addressed store, hash-verified

183
184#[cfg(feature = "apigw_rest")]
185fn into_proxy_request(ag: ApiGatewayProxyRequest) -> http::Request<Body> {
186 let http_method = ag.http_method;
187 let host = ag
188 .headers
189 .get(http::header::HOST)
190 .and_then(|s| s.to_str().ok())
191 .or(ag.request_context.domain_name.as_deref());
192 let raw_path = ag.path.unwrap_or_default();
193 let path = apigw_path_with_stage(&ag.request_context.stage, &raw_path);
194
195 let builder = http::Request::builder()
196 .uri(build_request_uri(
197 &path,
198 &ag.headers,
199 host,
200 Some((&ag.multi_value_query_string_parameters, &ag.query_string_parameters)),
201 ))
202 .extension(RawHttpPath(raw_path))
203 // multi-valued query string parameters are always a super
204 // set of singly valued query string parameters,
205 // when present, multi-valued query string parameters are preferred
206 .extension(QueryStringParameters(
207 if ag.multi_value_query_string_parameters.is_empty() {
208 ag.query_string_parameters
209 } else {
210 ag.multi_value_query_string_parameters
211 },
212 ))
213 .extension(PathParameters(QueryMap::from(ag.path_parameters)))
214 .extension(StageVariables(QueryMap::from(ag.stage_variables)))
215 .extension(RequestContext::ApiGatewayV1(ag.request_context));
216
217 // merge headers into multi_value_headers and make
218 // multi-value_headers our cannoncial source of request headers
219 let mut headers = ag.multi_value_headers;
220 headers.extend(ag.headers);
221
222 let base64 = ag.is_base64_encoded;
223 let mut req = builder
224 .body(
225 ag.body
226 .as_deref()
227 .map_or_else(Body::default, |b| Body::from_maybe_encoded(base64, b)),
228 )
229 .expect("failed to build request");
230
231 // no builder method that sets headers in batch
232 let _ = std::mem::replace(req.headers_mut(), headers);
233 let _ = std::mem::replace(req.method_mut(), http_method);
234
235 req
236}
237
238#[cfg(feature = "alb")]
239fn into_alb_request(alb: AlbTargetGroupRequest) -> http::Request<Body> {

Callers 1

fromMethod · 0.85

Calls 8

apigw_path_with_stageFunction · 0.85
build_request_uriFunction · 0.85
RawHttpPathClass · 0.85
PathParametersClass · 0.85
StageVariablesClass · 0.85
uriMethod · 0.80
is_emptyMethod · 0.80

Tested by

no test coverage detected