Skip to content

Commit

Permalink
refactor(api): [torrust#143] remove dummy api endpoint
Browse files Browse the repository at this point in the history
It was added to test Axum configuration.
  • Loading branch information
josecelano committed Jan 4, 2023
1 parent 43dbed9 commit 1395945
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 28 deletions.
5 changes: 0 additions & 5 deletions src/apis/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ use crate::api::resource::stats::Stats;
use crate::tracker::services::statistics::get_metrics;
use crate::tracker::Tracker;

#[allow(clippy::unused_async)]
pub async fn root() -> Json<Value> {
Json(json!({ "data": 42 }))
}

#[allow(clippy::unused_async)]
pub async fn get_stats(State(tracker): State<Arc<Tracker>>) -> Json<Value> {
Json(json!(Stats::from(get_metrics(tracker.clone()).await)))
Expand Down
4 changes: 1 addition & 3 deletions src/apis/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ use futures::Future;
use warp::hyper;

use super::middlewares::auth::auth;
use super::routes::{get_stats, root};
use super::routes::get_stats;
use crate::tracker;

pub fn start(socket_addr: SocketAddr, tracker: &Arc<tracker::Tracker>) -> impl Future<Output = hyper::Result<()>> {
let app = Router::new()
.route("/", get(root))
.route("/stats", get(get_stats).with_state(tracker.clone()))
.layer(middleware::from_fn_with_state(tracker.config.clone(), auth));

Expand All @@ -32,7 +31,6 @@ pub fn start_tls(
// todo: for the time being, it's just a copy & paste from start(...).

let app = Router::new()
.route("/", get(root))
.route("/stats", get(get_stats).with_state(tracker.clone()))
.layer(middleware::from_fn_with_state(tracker.config.clone(), auth));

Expand Down
20 changes: 0 additions & 20 deletions tests/tracker_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,6 @@ mod tracker_apis {
Endpoints:
Root (dummy endpoint to test Axum configuration. To be removed):
- [x] GET /
Stats:
- [ ] GET /api/stats
Expand All @@ -579,23 +576,6 @@ mod tracker_apis {
*/

mod for_entrypoint {
use crate::api::client::{Client, Query};
use crate::api::server::start_default_api;
use crate::api::Version;

#[tokio::test]
async fn test_entrypoint() {
let api_server = start_default_api(&Version::Axum).await;

let response = Client::new(api_server.get_connection_info(), &Version::Axum)
.get("", Query::default())
.await;

assert_eq!(response.status(), 200);
}
}

mod for_stats_resources {
use std::str::FromStr;

Expand Down

0 comments on commit 1395945

Please sign in to comment.