Style
This commit is contained in:
parent
b53267f406
commit
da98bfba8c
20 changed files with 80 additions and 61 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use std::fmt::Display;
|
||||
use std::path::Path;
|
||||
|
||||
#[must_use]
|
||||
pub fn default_server<P: AsRef<Path>>(challenges_snippet_path: P) -> String {
|
||||
format!(
|
||||
"server {{
|
||||
|
|
@ -12,6 +13,7 @@ pub fn default_server<P: AsRef<Path>>(challenges_snippet_path: P) -> String {
|
|||
)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn server_config<D: Display, C: AsRef<Path>, K: AsRef<Path>, T: Display, S: AsRef<Path>>(
|
||||
domain: D,
|
||||
cert_path: C,
|
||||
|
|
@ -53,6 +55,7 @@ server {{
|
|||
)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn php_snippet<SOCKET: AsRef<Path>, STATIC: AsRef<Path>>(
|
||||
index: &'static str,
|
||||
socket_path: SOCKET,
|
||||
|
|
@ -71,6 +74,7 @@ pub fn php_snippet<SOCKET: AsRef<Path>, STATIC: AsRef<Path>>(
|
|||
)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn redir_snippet(target: &str) -> String {
|
||||
format!(
|
||||
"location / {{
|
||||
|
|
@ -85,6 +89,7 @@ pub trait SocketSpec {
|
|||
}
|
||||
|
||||
impl<T: AsRef<Path>> SocketSpec for T {
|
||||
#[must_use]
|
||||
fn to_nginx(&self) -> String {
|
||||
format!("unix:{}:", self.as_ref().to_str().unwrap())
|
||||
}
|
||||
|
|
@ -94,17 +99,20 @@ impl<T: AsRef<Path>> SocketSpec for T {
|
|||
pub struct LocalTcpSocket(usize);
|
||||
|
||||
impl LocalTcpSocket {
|
||||
#[must_use]
|
||||
pub const fn new(x: usize) -> Self {
|
||||
Self(x)
|
||||
}
|
||||
}
|
||||
|
||||
impl SocketSpec for LocalTcpSocket {
|
||||
#[must_use]
|
||||
fn to_nginx(&self) -> String {
|
||||
format!("localhost:{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn proxy_snippet<S: SocketSpec, STATIC: AsRef<Path>>(
|
||||
socket_path: &S,
|
||||
static_path: STATIC,
|
||||
|
|
@ -125,6 +133,7 @@ pub fn proxy_snippet<S: SocketSpec, STATIC: AsRef<Path>>(
|
|||
)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn static_snippet<S: AsRef<Path>>(static_path: S) -> String {
|
||||
format!(
|
||||
"root {};
|
||||
|
|
@ -134,6 +143,7 @@ pub fn static_snippet<S: AsRef<Path>>(static_path: S) -> String {
|
|||
)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn dokuwiki_snippet() -> String {
|
||||
"
|
||||
location ~ /(data/|conf/|bin/|inc/|install.php) { deny all; }
|
||||
|
|
@ -149,6 +159,7 @@ pub fn dokuwiki_snippet() -> String {
|
|||
}".into()
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn nextcloud_snippet() -> String {
|
||||
"
|
||||
client_max_body_size 500M;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue