File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed
Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -63,14 +63,21 @@ async fn main() {
6363
6464 #[ cfg( not( debug_assertions) ) ]
6565 {
66- let tls_config =
67- RustlsConfig :: from_pem_file ( PathBuf :: from ( "cert.pem" ) , PathBuf :: from ( "privkey.pem" ) )
66+ if std:: env:: var ( "TLS" ) . is_ok ( ) {
67+ let tls_config =
68+ RustlsConfig :: from_pem_file ( PathBuf :: from ( "cert.pem" ) , PathBuf :: from ( "privkey.pem" ) )
69+ . await
70+ . expect ( "unable to open certificate files" ) ;
71+ axum_server:: bind_rustls ( addr, tls_config)
72+ . serve ( router. into_make_service ( ) )
6873 . await
69- . expect ( "unable to open certificate files" ) ;
70- axum_server:: bind_rustls ( addr, tls_config)
71- . serve ( router. into_make_service ( ) )
72- . await
73- . expect ( "unable to bind https server" ) ;
74+ . expect ( "unable to bind https server" ) ;
75+ } else {
76+ axum_server:: bind ( addr)
77+ . serve ( router. into_make_service ( ) )
78+ . await
79+ . expect ( "unable to bind http server" ) ;
80+ }
7481 }
7582}
7683
You can’t perform that action at this time.
0 commit comments