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)