Created
June 17, 2017 07:58
-
-
Save andete/b5ce0851041546449f3d577b520cb4f9 to your computer and use it in GitHub Desktop.
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
impl<'a, 'r> FromRequest<'a, 'r> for Lang { | |
type Error = (); | |
fn from_request(request: &'a Request<'r>) -> Outcome<Lang, ()> { | |
match request.cookies().get_private("lang") { | |
Some(r) => { | |
match Lang::from_str(r.value()) { | |
Ok(l) => Success(l), | |
Err(_) => Success(Lang::default()), | |
} | |
} | |
None => Success(Lang::default()), | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment