global: snapshot

This commit is contained in:
nym21
2026-02-13 16:54:09 +01:00
parent d18c872072
commit dfcb04484b
17 changed files with 485 additions and 265 deletions
@@ -27,10 +27,8 @@ where
T: Serialize;
fn new_text(value: &str, etag: &str) -> Self;
fn new_text_with(status: StatusCode, value: &str, etag: &str) -> Self;
fn new_text_cached(value: &str, params: &CacheParams) -> Self;
fn new_bytes(value: Vec<u8>, etag: &str) -> Self;
fn new_bytes_with(status: StatusCode, value: Vec<u8>, etag: &str) -> Self;
fn new_bytes_cached(value: Vec<u8>, params: &CacheParams) -> Self;
}
impl ResponseExtended for Response<Body> {
@@ -114,26 +112,4 @@ impl ResponseExtended for Response<Body> {
}
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()).unwrap();
let headers = response.headers_mut();
headers.insert_content_type_text_plain();
headers.insert_cache_control(&params.cache_control);
if let Some(etag) = &params.etag {
headers.insert_etag(etag);
}
response
}
fn new_bytes_cached(value: Vec<u8>, params: &CacheParams) -> Self {
let mut response = Response::builder().body(value.into()).unwrap();
let headers = response.headers_mut();
headers.insert_content_type_octet_stream();
headers.insert_cache_control(&params.cache_control);
if let Some(etag) = &params.etag {
headers.insert_etag(etag);
}
response
}
}