A0: contract stubs types, transport, fake and registry seams
Land the shared peer contracts: types, error mapping, transport trait, fake transport and fixtures, registry/proxy/health skeletons, the AppState.peers and Config.peers seams, the ping and peers route stubs, and unit plus integration tests. No loops, no network, feature off by default.
This commit is contained in:
1 parent
746b389a2b
commit
4bfb097be6
22 files changed
+1781
-1
No files matched your search
@@ -0,0 +1,41 @@
|
||||
//! GET /api/v1/ping: cheap authenticated liveness.
|
||||
//!
|
||||
//! `/healthz` does not validate a token, so a consolidator cannot use it to
|
||||
//! prove "API running with our credentials". This route sits behind the same
|
||||
//! auth layer as every other `/api/v1` route.
|
||||
|
||||
use axum::routing::get;
|
||||
use axum::{Json, Router};
|
||||
|
||||
use crate::state::AppState;
|
||||
|
||||
pub fn routes() -> Router<AppState> {
|
||||
Router::new().route("/ping", get(ping))
|
||||
}
|
||||
|
||||
async fn ping() -> Json<serde_json::Value> {
|
||||
Json(serde_json::json!({
|
||||
"status": "ok",
|
||||
"version": env!("CARGO_PKG_VERSION"),
|
||||
}))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use axum::http::StatusCode;
|
||||
|
||||
use crate::api::router;
|
||||
use crate::api::testutil::{get, json};
|
||||
use crate::config::Config;
|
||||
use crate::sources::fake::fake_state;
|
||||
|
||||
#[tokio::test]
|
||||
async fn ping_reports_version() {
|
||||
let app = router(fake_state(Config::default()));
|
||||
let (status, body) = get(&app, "/ping").await;
|
||||
assert_eq!(status, StatusCode::OK);
|
||||
let v = json(&body);
|
||||
assert_eq!(v["status"], "ok");
|
||||
assert_eq!(v["version"], env!("CARGO_PKG_VERSION"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user