33//! Typically these are exposed via the `request_context`
44//! request extension method provided by [lambda_http::RequestExt](../trait.RequestExt.html)
55//!
6- use crate :: ext:: { PathParameters , QueryStringParameters , StageVariables } ;
6+ use crate :: ext:: { PathParameters , QueryStringParameters , RawHttpPath , StageVariables } ;
77use aws_lambda_events:: alb:: { AlbTargetGroupRequest , AlbTargetGroupRequestContext } ;
88use aws_lambda_events:: apigw:: {
99 ApiGatewayProxyRequest , ApiGatewayProxyRequestContext , ApiGatewayV2httpRequest , ApiGatewayV2httpRequestContext ,
@@ -61,6 +61,8 @@ pub enum RequestOrigin {
6161
6262fn into_api_gateway_v2_request ( ag : ApiGatewayV2httpRequest ) -> http:: Request < Body > {
6363 let http_method = ag. request_context . http . method . clone ( ) ;
64+ let raw_path = ag. raw_path . unwrap_or_default ( ) ;
65+
6466 let builder = http:: Request :: builder ( )
6567 . uri ( {
6668 let scheme = ag
@@ -75,7 +77,7 @@ fn into_api_gateway_v2_request(ag: ApiGatewayV2httpRequest) -> http::Request<Bod
7577 . or ( ag. request_context . domain_name . as_deref ( ) )
7678 . unwrap_or_default ( ) ;
7779
78- let path = apigw_path_with_stage ( & ag. request_context . stage , ag . raw_path . as_deref ( ) . unwrap_or_default ( ) ) ;
80+ let path = apigw_path_with_stage ( & ag. request_context . stage , & raw_path) ;
7981 let mut url = format ! ( "{}://{}{}" , scheme, host, path) ;
8082
8183 if let Some ( query) = ag. raw_query_string {
@@ -84,6 +86,7 @@ fn into_api_gateway_v2_request(ag: ApiGatewayV2httpRequest) -> http::Request<Bod
8486 }
8587 url
8688 } )
89+ . extension ( RawHttpPath ( raw_path) )
8790 . extension ( QueryStringParameters ( ag. query_string_parameters ) )
8891 . extension ( PathParameters ( QueryMap :: from ( ag. path_parameters ) ) )
8992 . extension ( StageVariables ( QueryMap :: from ( ag. stage_variables ) ) )
@@ -115,10 +118,12 @@ fn into_api_gateway_v2_request(ag: ApiGatewayV2httpRequest) -> http::Request<Bod
115118
116119fn into_proxy_request ( ag : ApiGatewayProxyRequest ) -> http:: Request < Body > {
117120 let http_method = ag. http_method ;
121+ let raw_path = ag. path . unwrap_or_default ( ) ;
122+
118123 let builder = http:: Request :: builder ( )
119124 . uri ( {
120125 let host = ag. headers . get ( http:: header:: HOST ) . and_then ( |s| s. to_str ( ) . ok ( ) ) ;
121- let path = apigw_path_with_stage ( & ag. request_context . stage , & ag . path . unwrap_or_default ( ) ) ;
126+ let path = apigw_path_with_stage ( & ag. request_context . stage , & raw_path ) ;
122127
123128 let mut url = match host {
124129 None => path,
@@ -141,6 +146,7 @@ fn into_proxy_request(ag: ApiGatewayProxyRequest) -> http::Request<Body> {
141146 }
142147 url
143148 } )
149+ . extension ( RawHttpPath ( raw_path) )
144150 // multi-valued query string parameters are always a super
145151 // set of singly valued query string parameters,
146152 // when present, multi-valued query string parameters are preferred
@@ -178,6 +184,8 @@ fn into_proxy_request(ag: ApiGatewayProxyRequest) -> http::Request<Body> {
178184
179185fn into_alb_request ( alb : AlbTargetGroupRequest ) -> http:: Request < Body > {
180186 let http_method = alb. http_method ;
187+ let raw_path = alb. path . unwrap_or_default ( ) ;
188+
181189 let builder = http:: Request :: builder ( )
182190 . uri ( {
183191 let scheme = alb
@@ -191,7 +199,7 @@ fn into_alb_request(alb: AlbTargetGroupRequest) -> http::Request<Body> {
191199 . and_then ( |s| s. to_str ( ) . ok ( ) )
192200 . unwrap_or_default ( ) ;
193201
194- let mut url = format ! ( "{}://{}{}" , scheme, host, alb . path . unwrap_or_default ( ) ) ;
202+ let mut url = format ! ( "{}://{}{}" , scheme, host, & raw_path ) ;
195203 if !alb. multi_value_query_string_parameters . is_empty ( ) {
196204 url. push ( '?' ) ;
197205 url. push_str ( & alb. multi_value_query_string_parameters . to_query_string ( ) ) ;
@@ -202,6 +210,7 @@ fn into_alb_request(alb: AlbTargetGroupRequest) -> http::Request<Body> {
202210
203211 url
204212 } )
213+ . extension ( RawHttpPath ( raw_path) )
205214 // multi valued query string parameters are always a super
206215 // set of singly valued query string parameters,
207216 // when present, multi-valued query string parameters are preferred
0 commit comments