antithesis_intake/
http.rs

1//! Axum HTTP surface for the intake.
2//!
3//! This module composes the full router while the submodules keep protocol
4//! groups separate:
5//!
6//! - `datadog`: Datadog-compatible intake and health routes:
7//!   - `POST /api/v2/series`
8//!   - `POST /api/beta/sketches`
9//!   - `POST /api/v1/events_batch`
10//!   - `POST /api/v1/events`
11//!   - `POST /intake/`
12//!   - `POST /api/v1/check_run`
13//!   - `GET /api/v1/validate`
14//! - `antithesis`: private scenario-control routes used by Antithesis drivers:
15//!   - `GET /antithesis/metrics/{target}`
16//! - `middleware`: request body measurement used by payload assertions.
17//! - `state`: shared router state for one capture target.
18
19mod antithesis;
20mod datadog;
21pub(crate) mod middleware;
22pub mod state;
23
24use axum::{http::StatusCode, Router};
25
26use self::state::AppState;
27
28/// Memory backstop on the compressed body buffered before decompression. Sits above any Pyld05 spec limit.
29const MAX_COMPRESSED_BODY_BYTES: usize = 64 * 1024 * 1024;
30
31/// Caps the decompressed body a handler buffers. Exceeds every Pyld06 spec limit.
32const MAX_DECOMPRESSED_BODY_BYTES: usize = 64 * 1024 * 1024;
33
34/// Build the intake router. `/api/v2/series` fires payload assertions. Datadog endpoints answer
35/// 202. A malformed body gets 400. An oversized body gets 413. Unmatched paths answer 200.
36pub fn build_router(state: AppState) -> Router {
37    Router::new()
38        .merge(datadog::routes())
39        .merge(antithesis::routes())
40        .fallback(|| async { StatusCode::OK })
41        .with_state(state)
42}