diff --git a/lib/src/request/from_request.rs b/lib/src/request/from_request.rs index 9ce5d925..9d4b416b 100644 --- a/lib/src/request/from_request.rs +++ b/lib/src/request/from_request.rs @@ -5,7 +5,7 @@ use outcome::{self, IntoOutcome}; use request::Request; use outcome::Outcome::*; -use http::{Status, ContentType, Method, Cookies, Session}; +use http::{Status, ContentType, Accept, Method, Cookies, Session}; use http::uri::URI; /// Type alias for the `Outcome` of a `FromRequest` conversion. @@ -220,6 +220,17 @@ impl<'a, 'r> FromRequest<'a, 'r> for Session<'a> { } } +impl<'a, 'r> FromRequest<'a, 'r> for Accept { + type Error = (); + + fn from_request(request: &'a Request<'r>) -> Outcome { + match request.accept() { + Some(accept) => Success(accept), + None => Forward(()) + } + } +} + impl<'a, 'r> FromRequest<'a, 'r> for ContentType { type Error = ();