Skip to content

Commit

Permalink
feat(api): [#143] replace Warp API with Axum implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Jan 13, 2023
1 parent 8d32628 commit 337e12e
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions src/setup.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use std::net::SocketAddr;
use std::sync::Arc;

use log::warn;
use tokio::task::JoinHandle;

use crate::config::Configuration;
use crate::jobs::{http_tracker, torrent_cleanup, tracker_api, tracker_apis, udp_tracker};
use crate::jobs::{http_tracker, torrent_cleanup, tracker_apis, udp_tracker};
use crate::tracker;

/// # Panics
Expand Down Expand Up @@ -51,24 +50,9 @@ pub async fn setup(config: &Configuration, tracker: Arc<tracker::Tracker>) -> Ve
jobs.push(http_tracker::start_job(http_tracker_config, tracker.clone()));
}

// Start HTTP API server
// Start HTTP API
if config.http_api.enabled {
jobs.push(tracker_api::start_job(&config.http_api, tracker.clone()).await);
}

// Start HTTP APIs server (multiple API versions)
if config.http_api.enabled {
// Temporarily running the new API in the 1313 port
let bind_address = config.http_api.bind_address.clone();
let mut bind_socket: SocketAddr = bind_address
.parse()
.expect("bind address should be a valid socket address, for example 127.0.0.1:8080");
bind_socket.set_port(1313);

let mut http_apis_config = config.http_api.clone();
http_apis_config.bind_address = bind_socket.to_string();

jobs.push(tracker_apis::start_job(&http_apis_config, tracker.clone()).await);
jobs.push(tracker_apis::start_job(&config.http_api, tracker.clone()).await);
}

// Remove torrents without peers, every interval
Expand Down

0 comments on commit 337e12e

Please sign in to comment.