Add http api for debugging

This commit is contained in:
Igor Katson 2021-06-30 10:14:33 +01:00
parent 1cb7a7bbc6
commit a3e84e4a99
6 changed files with 359 additions and 15 deletions

View file

@ -0,0 +1,13 @@
use std::sync::Arc;
use warp::Filter;
use crate::torrent_state::TorrentState;
// This is just a stub for debugging, nothing useful here.
pub async fn make_and_run_http_api(state: Arc<TorrentState>) -> anyhow::Result<()> {
let dump_haves = warp::path("haves")
.map(move || format!("{:?}", state.locked.read().chunks.get_have_pieces()));
warp::serve(dump_haves).run(([127, 0, 0, 1], 3030)).await;
Ok(())
}