Skip to content

Commit 1bba485

Browse files
committed
remove duplicated code
1 parent 34b1103 commit 1bba485

File tree

1 file changed

+13
-27
lines changed
  • aggregation_mode/gateway/src

1 file changed

+13
-27
lines changed

aggregation_mode/gateway/src/http.rs

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,19 @@ impl GatewayServer {
108108
.route("/quotas/{address}", web::get().to(Self::get_quotas))
109109
});
110110

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+
111121
#[cfg(feature = "tls")]
112-
{
122+
let server = {
113123
let tls_port = self.config.tls_port;
114-
tracing::info!(
115-
"Starting HTTP server at http://{}:{}",
116-
self.config.ip,
117-
http_port
118-
);
119124
tracing::info!(
120125
"Starting HTTPS server at https://{}:{}",
121126
self.config.ip,
@@ -127,30 +132,11 @@ impl GatewayServer {
127132
.expect("Failed to load TLS configuration");
128133

129134
server
130-
.bind((self.config.ip.as_str(), http_port))
131-
.expect("To bind HTTP socket correctly")
132135
.bind_rustls_0_23((self.config.ip.as_str(), tls_port), tls_config)
133136
.expect("To bind HTTPS socket correctly with TLS")
134-
.run()
135-
.await
136-
.expect("Server to never end");
137-
}
138-
139-
#[cfg(not(feature = "tls"))]
140-
{
141-
tracing::info!(
142-
"Starting HTTP server at http://{}:{}",
143-
self.config.ip,
144-
http_port
145-
);
137+
};
146138

147-
server
148-
.bind((self.config.ip.as_str(), http_port))
149-
.expect("To bind HTTP socket correctly")
150-
.run()
151-
.await
152-
.expect("Server to never end");
153-
}
139+
server.run().await.expect("Server to never end");
154140
}
155141

156142
// Returns an OK response (code 200), no matters what receives in the request

0 commit comments

Comments
 (0)