@ -15,23 +15,29 @@ use std::marker::PhantomData;
use std ::path ::{ Path , PathBuf } ;
pub trait Policy {
#[ must_use ]
fn acme_user ( ) -> & 'static str {
"acme"
}
#[ must_use ]
fn user_home ( user_name : & str ) -> PathBuf {
format ! ( "/home/{}" , user_name ) . into ( )
Path ::new ( "/home" ) . join ( user_name )
}
#[ must_use ]
fn user_name_for_domain ( domain_name : & '_ str ) -> String {
domain_name . split ( '.' ) . rev ( ) . fold ( String ::new ( ) , | result , part | if result . is_empty ( ) { result } else { result + "_" } + part )
}
#[ must_use ]
fn php_version ( ) -> & 'static str {
"7.0"
}
#[ must_use ]
fn path_for_data ( name : impl Display ) -> PathBuf {
( "/root/data" . as_ref ( ) as & Path ) . join ( format ! ( "_{}" , name ) )
Path ::new ( "/root/data" ) . join ( format ! ( "_{}" , name ) )
}
}
@ -286,7 +292,7 @@ impl<D: AsRef<Path>, POLICY> ResourceLocator<ServeCustom<D>> for DefaultLocator<
resource : & ServeCustom < D > ,
) -> ( < ServeCustom < D > as Resource > ::Artifact , Self ::Prerequisites ) {
(
PathArtifact ::from ( ( "/etc/nginx/sites-enabled/" . as_ref ( ) as & Path ) . join ( & resource . 0 ) ) ,
PathArtifact ::from ( Path ::new ( "/etc/nginx/sites-enabled/" ) . join ( & resource . 0 ) ) ,
( ) ,
)
}
@ -298,7 +304,7 @@ impl<D: AsRef<Path>, P, POLICY> ResourceLocator<ServePhp<D, P>> for DefaultLocat
resource : & ServePhp < D , P > ,
) -> ( < ServePhp < D , P > as Resource > ::Artifact , Self ::Prerequisites ) {
(
PathArtifact ::from ( ( "/etc/nginx/sites-enabled/" . as_ref ( ) as & Path ) . join ( & resource . 0 ) ) ,
PathArtifact ::from ( Path ::new ( "/etc/nginx/sites-enabled/" ) . join ( & resource . 0 ) ) ,
( ) ,
)
}
@ -313,7 +319,7 @@ impl<D: AsRef<Path>, P, POLICY> ResourceLocator<ServeService<D, P>> for DefaultL
Self ::Prerequisites ,
) {
(
PathArtifact ::from ( ( "/etc/nginx/sites-enabled/" . as_ref ( ) as & Path ) . join ( & resource . 0 ) ) ,
PathArtifact ::from ( Path ::new ( "/etc/nginx/sites-enabled/" ) . join ( & resource . 0 ) ) ,
( ) ,
)
}
@ -325,7 +331,7 @@ impl<D: AsRef<Path>, POLICY> ResourceLocator<ServeRedir<D>> for DefaultLocator<P
resource : & ServeRedir < D > ,
) -> ( < ServeRedir < D > as Resource > ::Artifact , Self ::Prerequisites ) {
(
PathArtifact ::from ( ( "/etc/nginx/sites-enabled/" . as_ref ( ) as & Path ) . join ( & resource . 0 ) ) ,
PathArtifact ::from ( Path ::new ( "/etc/nginx/sites-enabled/" ) . join ( & resource . 0 ) ) ,
( ) ,
)
}
@ -340,7 +346,7 @@ impl<D: AsRef<Path>, P, POLICY> ResourceLocator<ServeStatic<D, P>> for DefaultLo
Self ::Prerequisites ,
) {
(
PathArtifact ::from ( ( "/etc/nginx/sites-enabled/" . as_ref ( ) as & Path ) . join ( & resource . 0 ) ) ,
PathArtifact ::from ( Path ::new ( "/etc/nginx/sites-enabled/" ) . join ( & resource . 0 ) ) ,
( ) ,
)
}