-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
277 additions
and
199 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod auth; | ||
pub mod normalize; | ||
pub mod pages; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use email_address::EmailAddress; | ||
use error::BrokerError; | ||
use futures::future; | ||
use http::{ContextHandle, HandlerResult}; | ||
use hyper::header::{CacheControl, CacheDirective, ContentType}; | ||
use hyper::server::Response; | ||
|
||
/// Request handler for the email normalization endpoint. | ||
/// | ||
/// Performs normalization of email addresses, for clients that cannot implement all the necessary | ||
/// parts of the relevant specifications. (Unicode, WHATWG, etc.) | ||
pub fn normalize(ctx_handle: &ContextHandle) -> HandlerResult { | ||
let mut ctx = ctx_handle.borrow_mut(); | ||
|
||
let input = try_get_input_param!(ctx, "email"); | ||
let parsed = match input.parse::<EmailAddress>() { | ||
Ok(addr) => addr, | ||
Err(_) => return Box::new(future::err(BrokerError::Input( | ||
"not a valid email address".to_owned()))), | ||
}; | ||
|
||
let res = Response::new() | ||
.with_header(ContentType::plaintext()) | ||
.with_header(CacheControl(vec![ | ||
CacheDirective::NoCache, | ||
CacheDirective::NoStore, | ||
])) | ||
.with_body(parsed.to_string()); | ||
Box::new(future::ok(res)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters