Skip to content

Commit

Permalink
transport: 🚪 HttpsUriWithoutTlsSupport is gated on tls feature
Browse files Browse the repository at this point in the history
  • Loading branch information
cratelyn committed May 20, 2024
1 parent 89f9583 commit 5675f2f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tonic/src/transport/service/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use super::io::BoxedIo;
#[cfg(feature = "tls")]
use super::tls::TlsConnector;
use http::Uri;
use std::fmt;
use std::task::{Context, Poll};
use tower::make::MakeConnection;
use tower_service::Service;
Expand Down Expand Up @@ -104,14 +103,17 @@ where
}

/// Error returned when trying to connect to an HTTPS endpoint without TLS enabled.
#[cfg(feature = "tls")]
#[derive(Debug)]
pub(crate) struct HttpsUriWithoutTlsSupport(());

impl fmt::Display for HttpsUriWithoutTlsSupport {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
#[cfg(feature = "tls")]
impl std::fmt::Display for HttpsUriWithoutTlsSupport {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Connecting to HTTPS without TLS enabled")
}
}

// std::error::Error only requires a type to impl Debug and Display
#[cfg(feature = "tls")]
impl std::error::Error for HttpsUriWithoutTlsSupport {}

0 comments on commit 5675f2f

Please sign in to comment.