File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1
1
use anyhow:: { anyhow, Context } ;
2
+ use http:: HeaderValue ;
2
3
use reqwest:: blocking:: Client ;
4
+ use secrecy:: { ExposeSecret , SecretString } ;
3
5
4
6
#[ derive( Clone , Debug ) ]
5
7
pub struct Fastly {
6
- api_token : String ,
8
+ api_token : SecretString ,
7
9
static_domain_name : String ,
8
10
}
9
11
10
12
impl Fastly {
11
13
pub fn from_environment ( ) -> Option < Self > {
12
- let api_token = dotenvy:: var ( "FASTLY_API_TOKEN" ) . ok ( ) ?;
14
+ let api_token = dotenvy:: var ( "FASTLY_API_TOKEN" ) . ok ( ) ?. into ( ) ;
13
15
let static_domain_name = dotenvy:: var ( "S3_CDN" ) . expect ( "missing S3_CDN" ) ;
14
16
15
17
Some ( Self {
@@ -43,8 +45,12 @@ impl Fastly {
43
45
) ;
44
46
trace ! ( ?url) ;
45
47
48
+ let api_token = self . api_token . expose_secret ( ) ;
49
+ let mut api_token = HeaderValue :: try_from ( api_token) ?;
50
+ api_token. set_sensitive ( true ) ;
51
+
46
52
let mut headers = reqwest:: header:: HeaderMap :: new ( ) ;
47
- headers. append ( "Fastly-Key" , self . api_token . parse ( ) ? ) ;
53
+ headers. append ( "Fastly-Key" , api_token) ;
48
54
49
55
debug ! ( "sending invalidation request to Fastly" ) ;
50
56
let response = client
You can’t perform that action at this time.
0 commit comments