git: reset

This commit is contained in:
k
2024-06-23 17:38:53 +02:00
commit a1a576d088
375 changed files with 40952 additions and 0 deletions

26
server/src/headers.rs Normal file
View File

@@ -0,0 +1,26 @@
use axum::http::{header, HeaderMap};
const STALE_IF_ERROR: u64 = 604800; // 1 Week
pub fn add_cors_to_headers(headers: &mut HeaderMap) {
headers.insert(header::ACCESS_CONTROL_ALLOW_ORIGIN, "*".parse().unwrap());
headers.insert(header::ACCESS_CONTROL_ALLOW_HEADERS, "*".parse().unwrap());
}
pub fn add_json_type_to_headers(headers: &mut HeaderMap) {
headers.insert(header::CONTENT_TYPE, "application/json".parse().unwrap());
}
pub fn add_cache_control_to_headers(
headers: &mut HeaderMap,
max_age: u64,
stale_while_revalidate: u64,
) {
headers.insert(
header::CACHE_CONTROL,
format!(
"public, max-age={max_age}, stale-while-revalidate={stale_while_revalidate}, stale-if-error={STALE_IF_ERROR}")
.parse()
.unwrap(),
);
}