MCPcopy Create free account
hub / github.com/Firstyear/opensuse-proxy-cache / ipxe_static

Function ipxe_static

opensuse-proxy-cache/src/main.rs:1468–1494  ·  view source on GitHub ↗
(extract::Path(fname): extract::Path<PathBuf>)

Source from the content-addressed store, hash-verified

1466}
1467
1468async fn ipxe_static(extract::Path(fname): extract::Path<PathBuf>) -> Response {
1469 #[cfg(target_os = "linux")]
1470 const IPXE_PATH: &str = "/usr/share/ipxe";
1471 #[cfg(target_os = "freebsd")]
1472 const IPXE_PATH: &str = "/usr/local/share/ipxe";
1473 #[cfg(target_os = "macos")]
1474 const IPXE_PATH: &str = "/tmp/ipxe";
1475
1476 let Some(rel_fname) = fname.file_name() else {
1477 return StatusCode::NOT_FOUND.into_response();
1478 };
1479
1480 // Get the abs path.
1481 let abs_path = Path::new(IPXE_PATH).join(rel_fname);
1482
1483 let n_file = match File::open(&abs_path).await {
1484 Ok(f) => f,
1485 Err(e) => {
1486 error!("{:?}", e);
1487 return StatusCode::INTERNAL_SERVER_ERROR.into_response();
1488 }
1489 };
1490
1491 let stream = Body::from_stream(ReaderStream::with_capacity(n_file, BUFFER_READ_PAGE));
1492
1493 (StatusCode::OK, stream).into_response()
1494}
1495
1496#[derive(Template)]
1497#[template(path = "ipxe.menu.html")]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected