Skip to content

Instantly share code, notes, and snippets.

@andete
Created June 17, 2017 08:00
Show Gist options
  • Save andete/7572bfddf3503f7f9b8f09c0157d90e9 to your computer and use it in GitHub Desktop.
Save andete/7572bfddf3503f7f9b8f09c0157d90e9 to your computer and use it in GitHub Desktop.
struct Referer {
url:String
}
impl<'a, 'r> FromRequest<'a, 'r> for Referer {
type Error = ();
fn from_request(request: &'a Request<'r>) -> Outcome<Referer, ()> {
match request.headers().get_one("Referer") {
Some(r) => Success(Referer { url:r.into() }),
None => Forward(()),
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment