Commit ab64d95 1 parent dca9ed1 commit ab64d95 Copy full SHA for ab64d95
File tree 3 files changed +11
-0
lines changed
configurations/development
3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -19,3 +19,4 @@ username = "username"
19
19
password = " password"
20
20
database = " test"
21
21
max_connections = 5
22
+ use_ssl = false
Original file line number Diff line number Diff line change @@ -24,11 +24,20 @@ pub struct DbConfig {
24
24
pub database : String ,
25
25
/// The maximum number of connections allowed in the connection pool.
26
26
pub max_connections : u32 ,
27
+ /// Whether to use SSL when connecting to the `PostgreSQL` server.
28
+ pub use_ssl : bool ,
27
29
}
28
30
29
31
impl Postgres {
30
32
pub async fn connect ( opt : & DbConfig ) -> ports:: storage:: Result < Self > {
33
+ let ssl_mode = if opt. use_ssl {
34
+ sqlx:: postgres:: PgSslMode :: Require
35
+ } else {
36
+ sqlx:: postgres:: PgSslMode :: Disable
37
+ } ;
38
+
31
39
let options = PgConnectOptions :: new ( )
40
+ . ssl_mode ( ssl_mode)
32
41
. username ( & opt. username )
33
42
. password ( & opt. password )
34
43
. database ( & opt. database )
Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ impl PostgresProcess {
111
111
password : self . password . clone ( ) ,
112
112
database : self . initial_db . clone ( ) ,
113
113
max_connections : 5 ,
114
+ use_ssl : false ,
114
115
} ;
115
116
let db = Postgres :: connect ( & config) . await ?;
116
117
You can’t perform that action at this time.
0 commit comments