mirror of https://github.com/rwf2/Rocket.git
Implement FromRequest for Accept.
This commit is contained in:
parent
c58ca894b7
commit
b102a6a497
|
@ -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<Self, Self::Error> {
|
||||
match request.accept() {
|
||||
Some(accept) => Success(accept),
|
||||
None => Forward(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'r> FromRequest<'a, 'r> for ContentType {
|
||||
type Error = ();
|
||||
|
||||
|
|
Loading…
Reference in New Issue