File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
rust-runtime/aws-smithy-http-server/src/layer Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ where
108108 }
109109
110110 fn call ( & mut self , req : Request < Body > ) -> Self :: Future {
111- if req. uri ( ) == self . layer . health_check_uri . as_ref ( ) {
111+ if req. uri ( ) . path ( ) == self . layer . health_check_uri . as_ref ( ) {
112112 let clone = self . layer . health_check_handler . clone ( ) ;
113113 let service = std:: mem:: replace ( & mut self . layer . health_check_handler , clone) ;
114114 let handler_future = service. oneshot ( req) ;
@@ -179,3 +179,32 @@ where
179179 }
180180 }
181181}
182+
183+ #[ cfg( test) ]
184+ mod tests {
185+ use super :: * ;
186+ use http:: Uri ;
187+ use tower:: { service_fn, ServiceExt } ;
188+
189+ #[ tokio:: test]
190+ async fn health_check_matches_path_with_scheme_and_authority ( ) {
191+ let layer = AlbHealthCheckLayer :: from_handler ( "/ping" , |_req| async { StatusCode :: OK } ) ;
192+
193+ let inner_service = service_fn ( |_req| async {
194+ Ok :: < _ , std:: convert:: Infallible > (
195+ Response :: builder ( )
196+ . status ( StatusCode :: IM_A_TEAPOT )
197+ . body ( crate :: body:: empty ( ) )
198+ . expect ( "infallible" ) ,
199+ )
200+ } ) ;
201+
202+ let service = layer. layer ( inner_service) ;
203+
204+ let uri: Uri = "https://example.com/ping" . parse ( ) . unwrap ( ) ;
205+ let request = Request :: builder ( ) . uri ( uri) . body ( Body :: empty ( ) ) . unwrap ( ) ;
206+
207+ let response = service. oneshot ( request) . await . unwrap ( ) ;
208+ assert_eq ! ( response. status( ) , StatusCode :: OK ) ;
209+ }
210+ }
You can’t perform that action at this time.
0 commit comments