global: snapshot

This commit is contained in:
nym21
2026-01-15 23:34:43 +01:00
parent b0d933a7ab
commit 967d2c7f35
67 changed files with 6854 additions and 5210 deletions
+15 -1
View File
@@ -1,6 +1,6 @@
use axum::{
body::Body,
http::{Response, StatusCode},
http::{HeaderMap, Response, StatusCode},
response::IntoResponse,
};
use serde::Serialize;
@@ -20,6 +20,9 @@ where
where
T: Serialize;
fn new_json_cached<T>(value: T, params: &CacheParams) -> Self
where
T: Serialize;
fn static_json<T>(headers: &HeaderMap, value: T) -> Self
where
T: Serialize;
fn new_text(value: &str, etag: &str) -> Self;
@@ -108,6 +111,17 @@ impl ResponseExtended for Response<Body> {
response
}
fn static_json<T>(headers: &HeaderMap, value: T) -> Self
where
T: Serialize,
{
let params = CacheParams::version();
if params.matches_etag(headers) {
return Self::new_not_modified();
}
Self::new_json_cached(value, &params)
}
fn new_text_cached(value: &str, params: &CacheParams) -> Self {
let mut response = Response::builder()
.body(value.to_string().into())