v0,28,2
This commit is contained in:
1 parent
d940f9995f
commit
65e082b9d1
61 files changed
+1225
-581
No files matched your search
+21
-11
@@ -470,15 +470,25 @@ fn anonymous_allowed(method: &Method, path: &str) -> bool {
|
||||
|
||||
const CERTIFICATE_API_KEY_HEADER: &str = "x-rustproxy-certificate-key";
|
||||
|
||||
fn certificate_api_operation(method: &Method, path: &str) -> bool {
|
||||
if method != Method::POST {
|
||||
return false;
|
||||
}
|
||||
matches!(
|
||||
path,
|
||||
"/api/certificates/deploy" | "/api/certificates/reload"
|
||||
) || path
|
||||
.strip_prefix("/api/certificates/")
|
||||
.and_then(|tail| tail.strip_suffix("/reload"))
|
||||
.is_some_and(crate::config::valid_id)
|
||||
#[derive(Clone, Debug)]
|
||||
enum CertificateApiOperation {
|
||||
Deploy,
|
||||
ReloadAll,
|
||||
ReloadOne(String),
|
||||
}
|
||||
|
||||
fn certificate_api_operation(method: &Method, path: &str) -> Option<CertificateApiOperation> {
|
||||
if method != Method::POST {
|
||||
return None;
|
||||
}
|
||||
if path == "/api/certificates/deploy" {
|
||||
return Some(CertificateApiOperation::Deploy);
|
||||
}
|
||||
if path == "/api/certificates/reload" {
|
||||
return Some(CertificateApiOperation::ReloadAll);
|
||||
}
|
||||
path.strip_prefix("/api/certificates/")
|
||||
.and_then(|tail| tail.strip_suffix("/reload"))
|
||||
.filter(|certificate_id| crate::config::valid_id(certificate_id))
|
||||
.map(|certificate_id| CertificateApiOperation::ReloadOne(certificate_id.to_owned()))
|
||||
}
|
||||
Reference in new issue
Block a user