@@ -86,7 +86,7 @@ impl GatewayServer {
8686
8787 pub async fn start ( & self ) {
8888 // Note: GatewayServer is thread safe so we can just clone it (no need to add mutexes)
89- let port = self . config . port ;
89+ let http_port = self . config . port ;
9090 let state = self . clone ( ) ;
9191
9292 // Note: This creates a new Prometheus server different from the one created in GatewayServer::new. The created
@@ -96,18 +96,6 @@ impl GatewayServer {
9696 . build ( )
9797 . unwrap ( ) ;
9898
99- #[ cfg( feature = "tls" ) ]
100- let protocol = "https" ;
101- #[ cfg( not( feature = "tls" ) ) ]
102- let protocol = "http" ;
103-
104- tracing:: info!(
105- "Starting server at {}://{}:{}" ,
106- protocol,
107- self . config. ip,
108- self . config. port
109- ) ;
110-
11199 let server = HttpServer :: new ( move || {
112100 App :: new ( )
113101 . app_data ( Data :: new ( state. clone ( ) ) )
@@ -120,21 +108,34 @@ impl GatewayServer {
120108 . route ( "/quotas/{address}" , web:: get ( ) . to ( Self :: get_quotas) )
121109 } ) ;
122110
111+ tracing:: info!(
112+ "Starting HTTP server at http://{}:{}" ,
113+ self . config. ip,
114+ http_port
115+ ) ;
116+
117+ let server = server
118+ . bind ( ( self . config . ip . as_str ( ) , http_port) )
119+ . expect ( "To bind HTTP socket correctly" ) ;
120+
123121 #[ cfg( feature = "tls" ) ]
124122 let server = {
123+ let tls_port = self . config . tls_port ;
124+ tracing:: info!(
125+ "Starting HTTPS server at https://{}:{}" ,
126+ self . config. ip,
127+ tls_port
128+ ) ;
129+
125130 let tls_config =
126131 Self :: load_tls_config ( & self . config . tls_cert_path , & self . config . tls_key_path )
127132 . expect ( "Failed to load TLS configuration" ) ;
133+
128134 server
129- . bind_rustls_0_23 ( ( self . config . ip . as_str ( ) , port ) , tls_config)
130- . expect ( "To bind socket correctly with TLS" )
135+ . bind_rustls_0_23 ( ( self . config . ip . as_str ( ) , tls_port ) , tls_config)
136+ . expect ( "To bind HTTPS socket correctly with TLS" )
131137 } ;
132138
133- #[ cfg( not( feature = "tls" ) ) ]
134- let server = server
135- . bind ( ( self . config . ip . as_str ( ) , port) )
136- . expect ( "To bind socket correctly" ) ;
137-
138139 server. run ( ) . await . expect ( "Server to never end" ) ;
139140 }
140141
0 commit comments