Skip to content

Commit

Permalink
Add sparse index support
Browse files Browse the repository at this point in the history
  • Loading branch information
k3d3 committed Feb 4, 2023
1 parent a6f62e4 commit 464f9e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,17 @@ pub async fn serve(path: PathBuf, socket_addr: SocketAddr, tls_paths: Option<Tls
},
);

// Handle sparse index requests at /index/
let sparse_index = warp::path("index")
.and(warp::fs::dir(path.join("crates.io-index")));

let routes = index
.or(static_dir)
.or(dist_dir)
.or(rustup_dir)
.or(crates_dir_native_format)
.or(crates_dir_condensed_format)
.or(sparse_index)
.or(git);

match tls_paths {
Expand Down
4 changes: 4 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
cat &lt;&lt;EOT > ~/.cargo/config
[source.panamax]
registry = "{{ host }}/git/crates.io-index"
[source.panamax-sparse]
registry = "{{ host }}/index/"

[source.crates-io]
# To use sparse index, change "panamax" to "panamax-sparse".
replace-with = "panamax"
EOT</pre>
</div>
Expand Down

0 comments on commit 464f9e6

Please sign in to comment.