@@ -256,9 +256,10 @@ impl RestCatalog {
256256 async fn context ( & self ) -> Result < & RestContext > {
257257 self . ctx
258258 . get_or_try_init ( || async {
259- let catalog_config = RestCatalog :: load_config ( & self . user_config ) . await ?;
259+ let client = HttpClient :: new ( & self . user_config ) ?;
260+ let catalog_config = RestCatalog :: load_config ( & client, & self . user_config ) . await ?;
260261 let config = self . user_config . clone ( ) . merge_with_config ( catalog_config) ;
261- let client = HttpClient :: new ( & config) ?;
262+ let client = client . update_with ( & config) ?;
262263
263264 Ok ( RestContext { config, client } )
264265 } )
@@ -268,9 +269,10 @@ impl RestCatalog {
268269 /// Load the runtime config from the server by user_config.
269270 ///
270271 /// It's required for a rest catalog to update it's config after creation.
271- async fn load_config ( user_config : & RestCatalogConfig ) -> Result < CatalogConfig > {
272- let client = HttpClient :: new ( user_config) ?;
273-
272+ async fn load_config (
273+ client : & HttpClient ,
274+ user_config : & RestCatalogConfig ,
275+ ) -> Result < CatalogConfig > {
274276 let mut request = client. request ( Method :: GET , user_config. config_endpoint ( ) ) ;
275277
276278 if let Some ( warehouse_location) = & user_config. warehouse {
@@ -280,6 +282,7 @@ impl RestCatalog {
280282 let config = client
281283 . query :: < CatalogConfig , ErrorResponse , OK > ( request. build ( ) ?)
282284 . await ?;
285+
283286 Ok ( config)
284287 }
285288
@@ -777,7 +780,7 @@ mod tests {
777780 "expires_in": 86400
778781 }"# ,
779782 )
780- . expect ( 2 )
783+ . expect ( 1 )
781784 . create_async ( )
782785 . await
783786 }
@@ -831,7 +834,7 @@ mod tests {
831834 "expires_in": 86400
832835 }"# ,
833836 )
834- . expect ( 2 )
837+ . expect ( 1 )
835838 . create_async ( )
836839 . await ;
837840
0 commit comments