Skip to main content

kellnr_common/
prefetch.rs

1use axum::body::Body;
2use axum::http::StatusCode;
3use axum::response::{IntoResponse, Response};
4use serde::Deserialize;
5
6#[derive(Deserialize, PartialEq, Eq, Debug, Clone)]
7pub struct Prefetch {
8    pub data: Vec<u8>,
9    pub etag: String,
10    pub last_modified: String,
11}
12
13impl IntoResponse for Prefetch {
14    fn into_response(self) -> Response {
15        Response::builder()
16            .header("Content-Length", self.data.len().to_string())
17            .header("ETag", self.etag)
18            .header("Last-Modified", self.last_modified)
19            .status(StatusCode::OK)
20            .body(Body::from(self.data))
21            .unwrap()
22            .into_response()
23    }
24}
25
26#[derive(Debug)]
27pub struct Headers {
28    pub if_none_match: Option<String>,
29    pub if_modified_since: Option<String>,
30}