1
1
use anyhow:: Result ;
2
2
use serde:: Deserialize ;
3
- use std:: fs:: read_to_string ;
3
+ use std:: fs:: read ;
4
4
use tracing:: { debug, info, info_span} ;
5
5
6
6
pub use listener:: { Listener , ProxyProtocol } ;
@@ -21,8 +21,9 @@ pub struct Api {
21
21
pub prom : Listener ,
22
22
}
23
23
24
+ const DEFAULT_ACME : & str = "https://acme-v02.api.letsencrypt.org/directory" ;
24
25
fn default_acme ( ) -> String {
25
- "https://acme-v02.api.letsencrypt.org/directory" . to_string ( )
26
+ DEFAULT_ACME . to_string ( )
26
27
}
27
28
28
29
#[ derive( Deserialize , Debug ) ]
@@ -53,10 +54,10 @@ pub fn load_config(config_path: Option<String>) -> Result<Config> {
53
54
let span = info_span ! ( "load_config" , config_path) ;
54
55
let _enter = span. enter ( ) ;
55
56
56
- let file = read_to_string ( config_path) ?;
57
+ let file = read ( config_path) ?;
57
58
debug ! ( file_length = file. len( ) , "Read file" ) ;
58
59
59
- let config = toml:: de:: from_slice :: < Config > ( file. as_ref ( ) ) ?;
60
+ let config = toml:: de:: from_slice :: < Config > ( & file) ?;
60
61
// redact db information
61
62
let config_str = format ! ( "{:?}" , config) . replace ( & config. general . db , "******" ) ;
62
63
info ! ( config = %config_str, "Deserialized config" ) ;
@@ -69,7 +70,7 @@ mod tests {
69
70
use std:: path:: Path ;
70
71
use tracing_test:: traced_test;
71
72
72
- use super :: load_config;
73
+ use super :: { default_acme , load_config, DEFAULT_ACME } ;
73
74
74
75
#[ test]
75
76
#[ traced_test]
@@ -82,4 +83,9 @@ mod tests {
82
83
let config = format ! ( "{:?}" , config) . replace ( "postgres://root@localhost/acme" , "******" ) ;
83
84
assert ! ( logs_contain( & config) ) ;
84
85
}
86
+
87
+ #[ test]
88
+ fn test_default_acme ( ) {
89
+ assert_eq ! ( DEFAULT_ACME , default_acme( ) ) ;
90
+ }
85
91
}
0 commit comments