forked from MIrrors/bin
Use dereferencing for request parameters
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use std::ops::Deref;
|
||||
|
||||
use rocket::Request;
|
||||
use rocket::request::{FromRequest, Outcome};
|
||||
|
||||
@@ -7,6 +9,14 @@ use rocket::request::{FromRequest, Outcome};
|
||||
/// and also anything calling us from the console or that we can't identify.
|
||||
pub struct IsPlaintextRequest(pub bool);
|
||||
|
||||
impl Deref for IsPlaintextRequest {
|
||||
type Target = bool;
|
||||
|
||||
fn deref(&self) -> &bool {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'r> FromRequest<'a, 'r> for IsPlaintextRequest {
|
||||
type Error = ();
|
||||
|
||||
@@ -30,6 +40,14 @@ impl<'a, 'r> FromRequest<'a, 'r> for IsPlaintextRequest {
|
||||
/// on the request.
|
||||
pub struct HostHeader<'a>(pub Option<&'a str>);
|
||||
|
||||
impl<'a> Deref for HostHeader<'a> {
|
||||
type Target = Option<&'a str>;
|
||||
|
||||
fn deref(&self) -> &Option<&'a str> {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'r> FromRequest<'a, 'r> for HostHeader<'a> {
|
||||
type Error = ();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user