Use dereferencing for request parameters
Diff
src/main.rs | 4 ++--
src/params.rs | 18 ++++++++++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
@@ -63,7 +63,7 @@
let paste = store_paste(data);
match host.0 {
match *host {
Some(host) => Ok(format!("https://{}/{}", host, paste)),
None => Ok(paste)
}
@@ -90,7 +90,7 @@
let entry = get_paste(key)?;
if plaintext.0 {
if *plaintext {
Some(Content(ContentType::Plain, entry))
} else {
Some(Content(ContentType::HTML, Render {
@@ -1,3 +1,5 @@
use std::ops::Deref;
use rocket::Request;
use rocket::request::{FromRequest, Outcome};
@@ -6,6 +8,14 @@
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 = ();
@@ -29,6 +39,14 @@
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 = ();