Database schema optimization - part 6

This commit is contained in:
mdecimus
2025-11-05 16:42:11 +01:00
parent a7815ffd6b
commit f33b5f5d66
24 changed files with 679 additions and 2113 deletions

View File

@@ -23,7 +23,7 @@ use hyper::{
use ring::signature::{EcdsaKeyPair, RsaKeyPair};
use spamfilter::SpamFilterConfig;
use std::{str::FromStr, sync::Arc};
use store::{BlobBackend, BlobStore, SearchStore, InMemoryStore, Store, Stores};
use store::{BlobBackend, BlobStore, InMemoryStore, SearchStore, Store, Stores};
use telemetry::Metrics;
use utils::config::{Config, utils::AsKey};
@@ -261,52 +261,3 @@ pub fn build_ecdsa_pem(
Ok(None) => Err("No ECDSA key found in PEM".to_string()),
}
}
pub(crate) fn parse_http_headers(config: &mut Config, prefix: impl AsKey) -> HeaderMap {
let prefix = prefix.as_key();
let mut headers = HeaderMap::new();
for (header, value) in config
.values((&prefix, "headers"))
.map(|(_, v)| {
if let Some((k, v)) = v.split_once(':') {
Ok((
HeaderName::from_str(k.trim()).map_err(|err| {
format!("Invalid header found in property \"{prefix}.headers\": {err}",)
})?,
HeaderValue::from_str(v.trim()).map_err(|err| {
format!("Invalid header found in property \"{prefix}.headers\": {err}",)
})?,
))
} else {
Err(format!(
"Invalid header found in property \"{prefix}.headers\": {v}",
))
}
})
.collect::<Result<Vec<(HeaderName, HeaderValue)>, String>>()
.map_err(|e| config.new_parse_error((&prefix, "headers"), e))
.unwrap_or_default()
{
headers.insert(header, value);
}
if let (Some(name), Some(secret)) = (
config.value((&prefix, "auth.username")),
config.value((&prefix, "auth.secret")),
) {
headers.insert(
AUTHORIZATION,
format!(
"Basic {}",
general_purpose::STANDARD.encode(format!("{}:{}", name, secret))
)
.parse()
.unwrap(),
);
} else if let Some(token) = config.value((&prefix, "auth.token")) {
headers.insert(AUTHORIZATION, format!("Bearer {}", token).parse().unwrap());
}
headers
}