File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,15 +10,16 @@ static SECRET_KEY: LazyLock<String> = LazyLock::new(|| {
1010 . expect ( "environment variable `TURNSTILE_SECRET_KEY` should be a valid string" )
1111} ) ;
1212
13+ /// The client for connecting to the CAPTCHA verification API.
14+ static CAPTCHA_CLIENT : LazyLock < reqwest:: Client > = LazyLock :: new ( || reqwest:: Client :: new ( ) ) ;
15+
1316/// Returns whether a Cloudflare Turnstile token is valid.
1417///
1518/// # Errors
1619///
1720/// Returns an error if the verification request fails or cannot be processed.
1821pub ( crate ) async fn verify ( token : & str ) -> Result < bool , reqwest:: Error > {
19- let client = reqwest:: Client :: new ( ) ;
20-
21- let outcome: Value = client
22+ let outcome: Value = CAPTCHA_CLIENT
2223 . post ( "https://challenges.cloudflare.com/turnstile/v0/siteverify" )
2324 . json ( & json ! ( {
2425 "secret" : * SECRET_KEY ,
You can’t perform that action at this time.
0 commit comments