about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tvix/nar-bridge/src/lib.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/tvix/nar-bridge/src/lib.rs b/tvix/nar-bridge/src/lib.rs
index 5f0e8c19d26a..46390e865971 100644
--- a/tvix/nar-bridge/src/lib.rs
+++ b/tvix/nar-bridge/src/lib.rs
@@ -1,3 +1,4 @@
+use axum::http::StatusCode;
 use axum::routing::{head, put};
 use axum::{routing::get, Router};
 use lru::LruCache;
@@ -50,6 +51,10 @@ impl AppState {
 pub fn gen_router(priority: u64) -> Router<AppState> {
     Router::new()
         .route("/", get(root))
+        // FUTUREWORK: respond for NARs that we still have in root_nodes (at least HEAD)
+        // This avoids some unnecessary NAR uploading from multiple concurrent clients, and is cheap.
+        .route("/nar/:nar_str", get(four_o_four))
+        .route("/nar/:nar_str", head(four_o_four))
         .route("/nar/:nar_str", put(nar::put))
         .route("/nar/tvix-castore/:root_node_enc", get(nar::get))
         .route("/:narinfo_str", get(narinfo::get))
@@ -61,6 +66,10 @@ async fn root() -> &'static str {
     "Hello from nar-bridge"
 }
 
+async fn four_o_four() -> Result<(), StatusCode> {
+    Err(StatusCode::NOT_FOUND)
+}
+
 async fn nix_cache_info(priority: u64) -> String {
     format!(
         "StoreDir: /nix/store\nWantMassQuery: 1\nPriority: {}\n",