File tree Expand file tree Collapse file tree
cloudflare-authenticator/src
cloudflare-dynamic-config/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ pub struct Config {
4040pub struct Authenticator {
4141 config : Config ,
4242 certs : Arc < Mutex < Certs > > ,
43+ client : reqwest:: Client ,
4344}
4445
4546#[ derive( Debug , Serialize , Deserialize ) ]
@@ -97,6 +98,7 @@ impl Authenticator {
9798 } ,
9899 public_certs : vec ! [ ] ,
99100 } ) ) ,
101+ client : reqwest:: Client :: new ( ) ,
100102 } ;
101103
102104 // Start the background task to update certs periodically
@@ -146,8 +148,8 @@ impl Authenticator {
146148 }
147149
148150 async fn fetch_certs ( & self ) -> Result < ( ) , ValidationError > {
149- let client = reqwest :: Client :: new ( ) ;
150- let response = client
151+ let response = self
152+ . client
151153 . get ( & format ! ( "{}/cdn-cgi/access/certs" , & self . config. api) )
152154 . header ( header:: CONTENT_TYPE , "application/json" )
153155 . send ( )
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ pub struct Config {
2020pub struct DynamicConfigManager {
2121 config : Config ,
2222 apps : Arc < Mutex < Vec < App > > > , // Use Arc and Mutex for shared access
23+ client : reqwest:: Client ,
2324}
2425
2526#[ derive( Error , Debug ) ]
@@ -41,6 +42,7 @@ impl DynamicConfigManager {
4142 let manager = Self {
4243 config,
4344 apps : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
45+ client : reqwest:: Client :: new ( ) ,
4446 } ;
4547
4648 // Start the background task to update apps periodically
@@ -63,8 +65,8 @@ impl DynamicConfigManager {
6365 async fn fetch_apps ( & self ) -> Result < ( ) , ConfigError > {
6466 let query_params = [ ( "match" , "any" ) , ( "ui_apps" , "true" ) ] ;
6567
66- let client = reqwest :: Client :: new ( ) ;
67- let response = client
68+ let response = self
69+ . client
6870 . get ( & format ! (
6971 "{}?{}" ,
7072 self . config. api. clone( ) ,
You can’t perform that action at this time.
0 commit comments