Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to expose missing/invalid reject names #447

Merged
merged 1 commit into from Feb 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/reject.rs
Expand Up @@ -506,6 +506,13 @@ pub struct MissingHeader {
name: &'static str,
}

impl MissingHeader {
/// Retrieve the name of the header that was missing
pub fn name(&self) -> &str {
self.name
}
}

impl ::std::fmt::Display for MissingHeader {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
write!(f, "Missing request header {:?}", self.name)
Expand All @@ -520,6 +527,13 @@ pub struct InvalidHeader {
name: &'static str,
}

impl InvalidHeader {
/// Retrieve the name of the header that was invalid
pub fn name(&self) -> &str {
self.name
}
}

impl ::std::fmt::Display for InvalidHeader {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
write!(f, "Invalid request header {:?}", self.name)
Expand All @@ -534,6 +548,13 @@ pub struct MissingCookie {
name: &'static str,
}

impl MissingCookie {
/// Retrieve the name of the cookie that was missing
pub fn name(&self) -> &str {
self.name
}
}

impl ::std::fmt::Display for MissingCookie {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
write!(f, "Missing request cookie {:?}", self.name)
Expand Down