@@ -70,6 +70,7 @@ pub use sonic_rs;
7070pub use tokio;
7171pub use tracing;
7272use tracing:: { info, warn, Instrument } ;
73+ pub mod tls;
7374
7475static GRAPHIQL_HTML : & str = include_str ! ( "../static/graphiql.html" ) ;
7576
@@ -188,7 +189,7 @@ pub async fn router_entrypoint(plugin_registry: PluginRegistry) -> Result<(), Ro
188189 paths. detect_conflicts ( & prometheus) ?;
189190
190191 let graphql_path = graphql_path. to_string ( ) ;
191- let maybe_error = web:: HttpServer :: new ( async move || {
192+ let server = web:: HttpServer :: new ( async move || {
192193 let landing_page_path = graphql_path. clone ( ) ;
193194 let prometheus = prometheus. clone ( ) ;
194195 web:: App :: new ( )
@@ -199,9 +200,22 @@ pub async fn router_entrypoint(plugin_registry: PluginRegistry) -> Result<(), Ro
199200 . default_service ( web:: to ( move || {
200201 landing_page_handler ( landing_page_path. clone ( ) )
201202 } ) )
202- } )
203- . bind ( & addr)
204- . map_err ( |err| RouterInitError :: HttpServerBindError ( addr, err) ) ?
203+ } ) ;
204+
205+ let tls_config = shared_state_clone
206+ . router_config
207+ . traffic_shaping
208+ . router
209+ . tls
210+ . as_ref ( ) ;
211+
212+ let maybe_error = if let Some ( tls_config) = tls_config {
213+ let rustls_config = tls:: build_rustls_config ( tls_config) ?;
214+ server. bind_rustls ( & addr, & rustls_config)
215+ } else {
216+ server. bind ( & addr)
217+ }
218+ . map_err ( |err| RouterInitError :: HttpServerBindError ( addr. to_string ( ) , err) ) ?
205219 . run ( )
206220 . await
207221 . map_err ( RouterInitError :: HttpServerStartError ) ;
0 commit comments