From f94b0c79c5c998fea58d788fa5952f363610c8f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Mon, 27 May 2019 17:53:10 +0200 Subject: [PATCH] move impl closer to mother struct --- plume-models/src/blogs.rs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/plume-models/src/blogs.rs b/plume-models/src/blogs.rs index ebd8fab5..dab6bbcc 100644 --- a/plume-models/src/blogs.rs +++ b/plume-models/src/blogs.rs @@ -53,6 +53,24 @@ impl AsRef for Host { } } +impl<'a, 'r> FromRequest<'a, 'r> for Host { + type Error = (); + + fn from_request(request: &'a Request<'r>) -> request::Outcome { + request + .headers() + .get_one("Host") + .and_then(|x| { + if Blog::list_custom_domains().contains(&x.to_string()) { + Some(Host::new(x)) + } else { + None + } + }) + .or_forward(()) + } +} + #[derive(Queryable, Identifiable, Clone, AsChangeset)] #[changeset_options(treat_none_as_null = "true")] pub struct Blog { @@ -342,24 +360,6 @@ impl Blog { } } -impl<'a, 'r> FromRequest<'a, 'r> for Host { - type Error = (); - - fn from_request(request: &'a Request<'r>) -> request::Outcome { - request - .headers() - .get_one("Host") - .and_then(|x| { - if Blog::list_custom_domains().contains(&x.to_string()) { - Some(Host::new(x)) - } else { - None - } - }) - .or_forward(()) - } -} - impl IntoId for Blog { fn into_id(self) -> Id { Id::new(self.ap_url)