feat: implement Nginx service with upstream management and configuration generation
This commit is contained in:
31
apps/api/src/services/nginx/traits/indentable.rs
Normal file
31
apps/api/src/services/nginx/traits/indentable.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
pub trait Indentable<T> {
|
||||
fn indent(&self, spaces: T) -> String;
|
||||
}
|
||||
|
||||
impl Indentable<usize> for &str {
|
||||
fn indent(&self, spaces: usize) -> String {
|
||||
let indent_str = " ".repeat(spaces);
|
||||
self.lines()
|
||||
.map(|line| format!("{}{}", indent_str, line))
|
||||
.collect::<Vec<String>>()
|
||||
.join("\n")
|
||||
}
|
||||
}
|
||||
|
||||
impl Indentable<Option<usize>> for String {
|
||||
fn indent(&self, spaces: Option<usize>) -> String {
|
||||
self.as_str().indent(spaces.unwrap_or(0))
|
||||
}
|
||||
}
|
||||
|
||||
impl Indentable<usize> for String {
|
||||
fn indent(&self, spaces: usize) -> String {
|
||||
self.as_str().indent(spaces)
|
||||
}
|
||||
}
|
||||
|
||||
impl Indentable<Option<usize>> for &str {
|
||||
fn indent(&self, spaces: Option<usize>) -> String {
|
||||
self.indent(spaces.unwrap_or(0))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user