@@ -23,6 +23,16 @@ fn default_mal_client_id(_ctx: &()) -> Result<Option<String>, HandlerError> {
23
23
Ok ( Some ( DEFAULT_MAL_CLIENT_ID . to_owned ( ) ) )
24
24
}
25
25
26
+ #[ cfg( debug_assertions) ]
27
+ pub const DEFAULT_GOOGLE_BOOKS_API_KEY : & str =
28
+ dotenvy_macro:: dotenv!( "DEFAULT_GOOGLE_BOOKS_API_KEY" ) ;
29
+ #[ cfg( not( debug_assertions) ) ]
30
+ pub const DEFAULT_GOOGLE_BOOKS_API_KEY : & str = env ! ( "DEFAULT_GOOGLE_BOOKS_API_KEY" ) ;
31
+
32
+ fn default_google_books_api_key ( _ctx : & ( ) ) -> Result < Option < String > , HandlerError > {
33
+ Ok ( Some ( DEFAULT_GOOGLE_BOOKS_API_KEY . to_owned ( ) ) )
34
+ }
35
+
26
36
#[ derive( Debug , Serialize , Deserialize , Clone , Config ) ]
27
37
#[ config( rename_all = "snake_case" , env_prefix = "ANIME_AND_MANGA_MAL_" ) ]
28
38
pub struct MalConfig {
@@ -116,6 +126,9 @@ pub struct OpenlibraryConfig {
116
126
#[ derive( Debug , Serialize , Deserialize , Clone , Config ) ]
117
127
#[ config( rename_all = "snake_case" , env_prefix = "BOOKS_GOOGLE_BOOKS_" ) ]
118
128
pub struct GoogleBooksConfig {
129
+ /// The API key to be used for the Google Books API.
130
+ #[ setting( default = default_google_books_api_key) ]
131
+ pub api_key : String ,
119
132
/// Whether to pass the raw query string to the search API.
120
133
pub pass_raw_query : bool ,
121
134
}
@@ -475,11 +488,11 @@ pub struct AppConfig {
475
488
}
476
489
477
490
impl AppConfig {
478
- // TODO: Denote masked values via attribute
479
491
pub fn masked_value ( & self ) -> Self {
480
492
let gt = || "****" . to_owned ( ) ;
481
493
let mut cl = self . clone ( ) ;
482
494
cl. anime_and_manga . mal . client_id = gt ( ) ;
495
+ cl. books . google_books . api_key = gt ( ) ;
483
496
cl. database . url = gt ( ) ;
484
497
cl. file_storage . s3_region = gt ( ) ;
485
498
cl. file_storage . s3_bucket_name = gt ( ) ;
0 commit comments