3
3
//! Typically these are exposed via the `request_context`
4
4
//! request extension method provided by [lambda_http::RequestExt](../trait.RequestExt.html)
5
5
//!
6
- use crate :: ext:: { PathParameters , QueryStringParameters , StageVariables } ;
6
+ use crate :: ext:: { PathParameters , QueryStringParameters , RawHttpPath , StageVariables } ;
7
7
use aws_lambda_events:: alb:: { AlbTargetGroupRequest , AlbTargetGroupRequestContext } ;
8
8
use aws_lambda_events:: apigw:: {
9
9
ApiGatewayProxyRequest , ApiGatewayProxyRequestContext , ApiGatewayV2httpRequest , ApiGatewayV2httpRequestContext ,
@@ -61,6 +61,8 @@ pub enum RequestOrigin {
61
61
62
62
fn into_api_gateway_v2_request ( ag : ApiGatewayV2httpRequest ) -> http:: Request < Body > {
63
63
let http_method = ag. request_context . http . method . clone ( ) ;
64
+ let raw_path = ag. raw_path . unwrap_or_default ( ) ;
65
+
64
66
let builder = http:: Request :: builder ( )
65
67
. uri ( {
66
68
let scheme = ag
@@ -75,7 +77,7 @@ fn into_api_gateway_v2_request(ag: ApiGatewayV2httpRequest) -> http::Request<Bod
75
77
. or ( ag. request_context . domain_name . as_deref ( ) )
76
78
. unwrap_or_default ( ) ;
77
79
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) ;
79
81
let mut url = format ! ( "{}://{}{}" , scheme, host, path) ;
80
82
81
83
if let Some ( query) = ag. raw_query_string {
@@ -84,6 +86,7 @@ fn into_api_gateway_v2_request(ag: ApiGatewayV2httpRequest) -> http::Request<Bod
84
86
}
85
87
url
86
88
} )
89
+ . extension ( RawHttpPath ( raw_path) )
87
90
. extension ( QueryStringParameters ( ag. query_string_parameters ) )
88
91
. extension ( PathParameters ( QueryMap :: from ( ag. path_parameters ) ) )
89
92
. extension ( StageVariables ( QueryMap :: from ( ag. stage_variables ) ) )
@@ -115,10 +118,12 @@ fn into_api_gateway_v2_request(ag: ApiGatewayV2httpRequest) -> http::Request<Bod
115
118
116
119
fn into_proxy_request ( ag : ApiGatewayProxyRequest ) -> http:: Request < Body > {
117
120
let http_method = ag. http_method ;
121
+ let raw_path = ag. path . unwrap_or_default ( ) ;
122
+
118
123
let builder = http:: Request :: builder ( )
119
124
. uri ( {
120
125
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 ) ;
122
127
123
128
let mut url = match host {
124
129
None => path,
@@ -141,6 +146,7 @@ fn into_proxy_request(ag: ApiGatewayProxyRequest) -> http::Request<Body> {
141
146
}
142
147
url
143
148
} )
149
+ . extension ( RawHttpPath ( raw_path) )
144
150
// multi-valued query string parameters are always a super
145
151
// set of singly valued query string parameters,
146
152
// when present, multi-valued query string parameters are preferred
@@ -178,6 +184,8 @@ fn into_proxy_request(ag: ApiGatewayProxyRequest) -> http::Request<Body> {
178
184
179
185
fn into_alb_request ( alb : AlbTargetGroupRequest ) -> http:: Request < Body > {
180
186
let http_method = alb. http_method ;
187
+ let raw_path = alb. path . unwrap_or_default ( ) ;
188
+
181
189
let builder = http:: Request :: builder ( )
182
190
. uri ( {
183
191
let scheme = alb
@@ -191,7 +199,7 @@ fn into_alb_request(alb: AlbTargetGroupRequest) -> http::Request<Body> {
191
199
. and_then ( |s| s. to_str ( ) . ok ( ) )
192
200
. unwrap_or_default ( ) ;
193
201
194
- let mut url = format ! ( "{}://{}{}" , scheme, host, alb . path . unwrap_or_default ( ) ) ;
202
+ let mut url = format ! ( "{}://{}{}" , scheme, host, & raw_path ) ;
195
203
if !alb. multi_value_query_string_parameters . is_empty ( ) {
196
204
url. push ( '?' ) ;
197
205
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> {
202
210
203
211
url
204
212
} )
213
+ . extension ( RawHttpPath ( raw_path) )
205
214
// multi valued query string parameters are always a super
206
215
// set of singly valued query string parameters,
207
216
// when present, multi-valued query string parameters are preferred
0 commit comments