feat: Add health check endpoint
Introduce a new health check endpoint at `/api/health`. This endpoint returns a JSON response indicating the server's status and configuration details, such as the port, data path, and configured URLs for external services. This change also refactors the application setup by: - Creating a `lib.rs` file to house the `create_router` function, making it reusable for both the main application and integration tests. - Moving configuration loading logic into `main.rs` and passing it as a shared state (`Arc<Config>`) to the router. - Adding a unit test (`health_test.rs`) to verify the functionality of the health check endpoint. - Updating `Cargo.toml` and `Cargo.lock` to include the `tower` dependency, which is used for testing.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
pub mod config;
|
||||
pub mod error;
|
||||
pub mod routes;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum::Router;
|
||||
|
||||
use config::Config;
|
||||
|
||||
/// Build the application router. Used by main.rs and integration tests.
|
||||
pub fn create_router(config: Arc<Config>) -> Router {
|
||||
routes::api_router().with_state(config)
|
||||
}
|
||||
Reference in New Issue
Block a user