specify listener in error messages and logs

The "listening for incoming traffic on ..." log line is new, but
something I've wanted even when we only supported one listener.

I considered getting rid of `clippy::too_many_lines` by factoring out
the construction of `app` to a separate function, but found that
specifying it's type (or relevant traits) got quite hairy.
This commit is contained in:
Benjamin Lee 2024-06-08 12:52:13 -07:00
parent f7d7952f9b
commit 4f041f9153
No known key found for this signature in database
GPG key ID: FB9624E2885D55A4
3 changed files with 36 additions and 11 deletions

View file

@ -1,5 +1,6 @@
use std::{
borrow::Cow,
fmt::{self, Display},
net::{IpAddr, Ipv4Addr},
path::{Path, PathBuf},
};
@ -96,7 +97,7 @@ pub(crate) struct TlsConfig {
pub(crate) key: String,
}
#[derive(Debug, Deserialize)]
#[derive(Clone, Debug, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub(crate) enum ListenConfig {
Tcp {
@ -109,6 +110,23 @@ pub(crate) enum ListenConfig {
},
}
impl Display for ListenConfig {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ListenConfig::Tcp {
address,
port,
tls: false,
} => write!(f, "http://{address}:{port}"),
ListenConfig::Tcp {
address,
port,
tls: true,
} => write!(f, "https://{address}:{port}"),
}
}
}
fn false_fn() -> bool {
false
}