@@ -6,7 +6,7 @@ use http::HeaderMap;
6
6
use lambda_http:: {
7
7
handler,
8
8
lambda_runtime:: { self , Context } ,
9
- Body , IntoResponse , Request , Response ,
9
+ Body , IntoResponse , Request , RequestExt , Response ,
10
10
} ;
11
11
use log:: * ;
12
12
use nix:: sys:: signal:: { kill, Signal } ;
@@ -22,6 +22,7 @@ use std::thread;
22
22
use std:: time:: { Duration , Instant } ;
23
23
use tokio_retry:: strategy:: FixedInterval ;
24
24
use tokio_retry:: Retry ;
25
+ use url:: form_urlencoded:: Serializer ;
25
26
26
27
type Error = Box < dyn std:: error:: Error + Send + Sync + ' static > ;
27
28
static HTTP_CLIENT : OnceCell < Client > = OnceCell :: new ( ) ;
@@ -144,8 +145,25 @@ async fn http_proxy_handler(event: Request, _: Context) -> Result<impl IntoRespo
144
145
"http://127.0.0.1:{}" ,
145
146
env:: var( "PORT" ) . unwrap_or_else( |_| "8080" . to_string( ) )
146
147
) ;
148
+ let query_params = event. query_string_parameters ( ) ;
149
+ debug ! ( "query_params are {:#?}" , query_params) ;
150
+
147
151
let ( parts, body) = event. into_parts ( ) ;
148
- let app_url = app_host + parts. uri . path_and_query ( ) . unwrap ( ) . as_str ( ) ;
152
+ let mut app_url = app_host + parts. uri . path ( ) ;
153
+
154
+ // append query parameters to app_url
155
+ if !query_params. is_empty ( ) {
156
+ app_url. push ( '?' ) ;
157
+ let mut serializer = Serializer :: new ( & mut app_url) ;
158
+ for ( key, _) in query_params. iter ( ) {
159
+ for value in query_params. get_all ( key) . unwrap ( ) . iter ( ) {
160
+ serializer. append_pair ( key, value) ;
161
+ }
162
+ }
163
+ serializer. finish ( ) ;
164
+ }
165
+ debug ! ( "app_url is {:#?}" , app_url) ;
166
+
149
167
let app_response = HTTP_CLIENT
150
168
. get ( )
151
169
. unwrap ( )
0 commit comments