(
config: &openshell_core::Config,
sandbox: &str,
service: &str,
)
| 47 | } |
| 48 | |
| 49 | pub fn endpoint_url( |
| 50 | config: &openshell_core::Config, |
| 51 | sandbox: &str, |
| 52 | service: &str, |
| 53 | ) -> Option<String> { |
| 54 | let host = endpoint_host(&config.service_routing, sandbox, service)?; |
| 55 | let scheme = endpoint_scheme(config); |
| 56 | let port = config.bind_address.port(); |
| 57 | let include_port = !matches!((scheme, port), ("https", 443) | ("http", 80)); |
| 58 | Some(if include_port { |
| 59 | format!("{scheme}://{host}:{port}/") |
| 60 | } else { |
| 61 | format!("{scheme}://{host}/") |
| 62 | }) |
| 63 | } |
| 64 | |
| 65 | fn endpoint_scheme(config: &openshell_core::Config) -> &'static str { |
| 66 | if config.tls.is_none() |
no test coverage detected