Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bin/http_health_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async fn main() {
let args: Vec<String> = env::args().collect();
if args.len() != 2 {
eprintln!("Usage: cargo run --bin http_health_check <HEALTH_URL>");
eprintln!("Example: cargo run --bin http_health_check http://127.0.0.1:1212/health_check");
eprintln!("Example: cargo run --bin http_health_check http://127.0.0.1:1212/api/health_check");
std::process::exit(1);
}

Expand Down
2 changes: 1 addition & 1 deletion src/servers/apis/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ pub fn router(tracker: Arc<Tracker>) -> Router {
tracker.config.clone(),
v1::middlewares::auth::auth,
))
.route("/health_check", get(health_check_handler))
.route(&format!("{api_url_prefix}/health_check"), get(health_check_handler))
.layer(CompressionLayer::new())
}
4 changes: 2 additions & 2 deletions src/servers/apis/v1/context/health_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
//!
//! # Health Check
//!
//! `GET /health_check`
//! `GET /api/health_check`
//!
//! Returns the API status.
//!
//! **Example request**
//!
//! ```bash
//! curl "http://127.0.0.1:1212/health_check"
//! curl "http://127.0.0.1:1212/api/health_check"
//! ```
//!
//! **Example response** `200`
Expand Down
2 changes: 2 additions & 0 deletions src/servers/apis/v1/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ use crate::core::Tracker;
/// Add the routes for the v1 API.
pub fn add(prefix: &str, router: Router, tracker: Arc<Tracker>) -> Router {
let v1_prefix = format!("{prefix}/v1");

let router = auth_key::routes::add(&v1_prefix, router, tracker.clone());
let router = stats::routes::add(&v1_prefix, router, tracker.clone());
let router = whitelist::routes::add(&v1_prefix, router, tracker.clone());

torrent::routes::add(&v1_prefix, router, tracker)
}
2 changes: 1 addition & 1 deletion src/servers/health_check_api/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async fn api_health_check(config: &HttpApi) -> Option<Json<Report>> {
let addr: SocketAddr = config.bind_address.parse().expect("invalid socket address for API");

if addr.port() != UNKNOWN_PORT {
let health_check_url = format!("http://{addr}/health_check");
let health_check_url = format!("http://{addr}/api/health_check");

if !get_req_is_ok(&health_check_url).await {
return Some(responses::error(format!(
Expand Down
2 changes: 1 addition & 1 deletion tests/servers/api/v1/contract/context/health_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::servers::api::v1::client::get;
async fn health_check_endpoint_should_return_status_ok_if_api_is_running() {
let test_env = running_test_environment(configuration::ephemeral()).await;

let url = format!("http://{}/health_check", test_env.get_connection_info().bind_address);
let url = format!("http://{}/api/health_check", test_env.get_connection_info().bind_address);

let response = get(&url, None).await;

Expand Down