(extract::Path(fname): extract::Path<PathBuf>)
| 1466 | } |
| 1467 | |
| 1468 | async 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")] |
nothing calls this directly
no outgoing calls
no test coverage detected