Skip to content

Commit 0acf146

Browse files
committed
docs: better ParseClientIpSourceError, closes #43
1 parent 3e926c7 commit 0acf146

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ define_extractor!(
114114
#[derive(Debug, Clone, Copy)]
115115
pub struct ClientIp(pub IpAddr);
116116

117-
/// [`ClientIp`] source configuration
117+
/// [`ClientIp`] source configuration.
118+
///
119+
/// String parsing and serde use the exact PascalCase variant name, for example
120+
/// `ConnectInfo` or `RightmostXForwardedFor`.
118121
#[non_exhaustive]
119122
#[derive(Clone, Debug, Eq, PartialEq)]
120123
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
@@ -158,7 +161,11 @@ pub struct ParseClientIpSourceError(String);
158161

159162
impl fmt::Display for ParseClientIpSourceError {
160163
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
161-
write!(f, "Invalid ClientIpSource value {}", self.0)
164+
write!(
165+
f,
166+
"Invalid ClientIpSource value {}. Expected an exact PascalCase ClientIpSource variant name",
167+
self.0
168+
)
162169
}
163170
}
164171

0 commit comments

Comments
 (0)