Skip to content

Commit

Permalink
refactor(http): [#160] reorganize dirs for Axum and Warp HTTP tracker…
Browse files Browse the repository at this point in the history
… implementations

We are going to start sharing code bettween both implementation (Warp
and Axum). We need to keep common code separated because Warp
implementation will be removed when Axum implementation is finished.
  • Loading branch information
josecelano committed Feb 9, 2023
1 parent 9c25feb commit 995397e
Show file tree
Hide file tree
Showing 20 changed files with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ where
#[cfg(test)]
mod tests {
use super::AnnounceParams;
use crate::http::axum::query::Query;
use crate::http::axum_implementation::query::Query;
use crate::protocol::info_hash::InfoHash;
use crate::tracker::peer;

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl Query {
#[cfg(test)]
mod tests {
use super::Query;
use crate::http::axum::query::Param;
use crate::http::axum_implementation::query::Param;

#[test]
fn it_should_parse_the_query_params_from_an_url_query_string() {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 3 additions & 11 deletions src/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,10 @@
//!

use serde::{Deserialize, Serialize};
pub mod axum;
pub mod error;
pub mod filters;
pub mod handlers;
pub mod percent_encoding;
pub mod request;
pub mod response;
pub mod routes;
pub mod server;

pub type Bytes = u64;
pub type WebResult<T> = std::result::Result<T, warp::Rejection>;
pub mod axum_implementation;
pub mod percent_encoding;
pub mod warp_implementation;

#[derive(Serialize, Deserialize, Copy, Clone, PartialEq, Eq, Debug)]
pub enum Version {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use std::sync::Arc;
use warp::{reject, Filter, Rejection};

use super::error::Error;
use super::percent_encoding::{percent_decode_info_hash, percent_decode_peer_id};
use super::{request, WebResult};
use crate::http::percent_encoding::{percent_decode_info_hash, percent_decode_peer_id};
use crate::protocol::common::MAX_SCRAPE_TORRENTS;
use crate::protocol::info_hash::InfoHash;
use crate::tracker::{self, auth, peer};
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions src/http/warp_implementation/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use warp::Rejection;

pub mod error;
pub mod filters;
pub mod handlers;
pub mod request;
pub mod response;
pub mod routes;
pub mod server;

pub type Bytes = u64;
pub type WebResult<T> = std::result::Result<T, Rejection>;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::net::IpAddr;

use serde::Deserialize;

use crate::http::Bytes;
use crate::http::warp_implementation::Bytes;
use crate::protocol::info_hash::InfoHash;
use crate::tracker::peer;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/jobs/http_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use tokio::sync::oneshot;
use tokio::task::JoinHandle;

use crate::config::HttpTracker;
use crate::http::axum::server;
use crate::http::server::Http;
use crate::http::axum_implementation::server;
use crate::http::warp_implementation::server::Http;
use crate::http::Version;
use crate::tracker;

Expand Down
4 changes: 2 additions & 2 deletions src/tracker/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde;
use serde::Serialize;
use thiserror::Error;

use crate::http::request::Announce;
use crate::http::warp_implementation::request::Announce;
use crate::protocol::clock::{Current, DurationSinceUnixEpoch, Time};
use crate::protocol::common::{AnnounceEventDef, NumberOfBytesDef};
use crate::protocol::utils::ser_unix_time_value;
Expand Down Expand Up @@ -599,7 +599,7 @@ mod test {
mod torrent_peer_constructor_from_for_http_requests {
use std::net::{IpAddr, Ipv4Addr};

use crate::http::request::Announce;
use crate::http::warp_implementation::request::Announce;
use crate::protocol::info_hash::InfoHash;
use crate::tracker::peer::{self, Peer};

Expand Down

0 comments on commit 995397e

Please sign in to comment.