move impl closer to mother struct
This commit is contained in:
		
							parent
							
								
									b09b51c74b
								
							
						
					
					
						commit
						f94b0c79c5
					
				@ -53,6 +53,24 @@ impl AsRef<str> for Host {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl<'a, 'r> FromRequest<'a, 'r> for Host {
 | 
				
			||||||
 | 
					    type Error = ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn from_request(request: &'a Request<'r>) -> request::Outcome<Host, ()> {
 | 
				
			||||||
 | 
					        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)]
 | 
					#[derive(Queryable, Identifiable, Clone, AsChangeset)]
 | 
				
			||||||
#[changeset_options(treat_none_as_null = "true")]
 | 
					#[changeset_options(treat_none_as_null = "true")]
 | 
				
			||||||
pub struct Blog {
 | 
					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<Host, ()> {
 | 
					 | 
				
			||||||
        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 {
 | 
					impl IntoId for Blog {
 | 
				
			||||||
    fn into_id(self) -> Id {
 | 
					    fn into_id(self) -> Id {
 | 
				
			||||||
        Id::new(self.ap_url)
 | 
					        Id::new(self.ap_url)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user