Skip to content

Commit 54c0cb9

Browse files
committed
Remove embedded opengraph fallback asset
Amp-Thread-ID: https://ampcode.com/threads/T-019ce7d9-9919-731b-9304-01df20592607
1 parent e27db96 commit 54c0cb9

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed

crates/statespace-server/src/server.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::content::{ContentResolver, LocalContentResolver};
44
use crate::error::ErrorExt;
5-
use crate::templates::{FAVICON_SVG, OPENGRAPH_PNG};
5+
use crate::templates::FAVICON_SVG;
66
use axum::{
77
Json, Router,
88
extract::{Path, Query, State},
@@ -179,12 +179,15 @@ async fn favicon_handler(State(state): State<ServerState>) -> Response {
179179
}
180180

181181
async fn opengraph_handler(State(state): State<ServerState>) -> Response {
182-
let bytes = match fs::read(state.content_root.join("opengraph.png")).await {
183-
Ok(custom) => custom,
184-
Err(_) => OPENGRAPH_PNG.to_vec(),
185-
};
186-
187-
(StatusCode::OK, [(header::CONTENT_TYPE, "image/png")], bytes).into_response()
182+
match fs::read(state.content_root.join("opengraph.png")).await {
183+
Ok(custom) => (
184+
StatusCode::OK,
185+
[(header::CONTENT_TYPE, "image/png")],
186+
custom,
187+
)
188+
.into_response(),
189+
Err(_) => StatusCode::NOT_FOUND.into_response(),
190+
}
188191
}
189192

190193
async fn file_handler(
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//! Embedded templates (AGENTS.md, favicon.svg, opengraph.png).
1+
//! Embedded templates (AGENTS.md, favicon.svg).
22
//!
33
//! Re-exported from the shared `statespace-templates` crate.
44
5-
pub use statespace_templates::{AGENTS_MD, FAVICON_SVG, OPENGRAPH_PNG};
5+
pub use statespace_templates::{AGENTS_MD, FAVICON_SVG};

crates/statespace-templates/src/lib.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ pub const README_MD: &str = include_str!("README.md");
66

77
pub const FAVICON_SVG: &str = include_str!("favicon.svg");
88

9-
pub const OPENGRAPH_PNG: &[u8] = include_bytes!("opengraph.png");
10-
119
#[cfg(test)]
1210
mod tests {
1311
use super::*;
@@ -23,9 +21,4 @@ mod tests {
2321
assert!(FAVICON_SVG.starts_with("<?xml"));
2422
assert!(FAVICON_SVG.contains("<svg"));
2523
}
26-
27-
#[test]
28-
fn opengraph_is_valid_png() {
29-
assert!(OPENGRAPH_PNG.starts_with(&[0x89, b'P', b'N', b'G', 0x0D, 0x0A, 0x1A, 0x0A]));
30-
}
3124
}
-16.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)