relay_server/endpoints/
mod.rs1mod attachments;
7mod autoscaling;
8mod batch_metrics;
9mod batch_outcomes;
10mod common;
11mod envelope;
12mod forward;
13mod health_check;
14mod minidump;
15mod monitor;
16mod nel;
17mod otlp_log;
18mod otlp_traces;
19#[cfg(sentry)]
20mod playstation;
21mod project_configs;
22mod public_keys;
23mod security_report;
24mod statics;
25mod store;
26mod unreal;
27
28use axum::extract::DefaultBodyLimit;
29use axum::routing::{Router, any, get, post};
30use relay_config::Config;
31
32use crate::middlewares;
33use crate::service::ServiceState;
34
35const BATCH_JSON_BODY_LIMIT: usize = 50_000_000; #[rustfmt::skip]
39pub fn routes(config: &Config) -> Router<ServiceState>{
40 let internal_routes = Router::new()
42 .route("/api/relay/healthcheck/{kind}/", get(health_check::handle))
43 .route("/api/relay/autoscaling/", get(autoscaling::handle))
44 .route("/api/relay/{*not_found}", any(statics::not_found));
46
47 let web_routes = Router::new()
49 .route("/api/0/relays/projectconfigs/", post(project_configs::handle))
50 .route("/api/0/relays/publickeys/", post(public_keys::handle))
51 .route("/api/0/relays/live/", get(health_check::handle_live))
53 .route_layer(DefaultBodyLimit::max(crate::constants::MAX_JSON_SIZE));
54
55 let batch_routes = Router::new()
56 .route("/api/0/relays/outcomes/", post(batch_outcomes::handle))
57 .route("/api/0/relays/metrics/", post(batch_metrics::handle))
58 .route_layer(DefaultBodyLimit::max(BATCH_JSON_BODY_LIMIT));
59
60 let store_routes = Router::new()
62 .route("/api/store/", store::route(config))
64 .route("/api/{project_id}/cron/{monitor_slug}/{sentry_key}", monitor::route(config))
66 .route("/api/{project_id}/cron/{monitor_slug}/{sentry_key}/", monitor::route(config))
67 .route("/api/{project_id}/cron/{monitor_slug}", monitor::route(config))
68 .route("/api/{project_id}/cron/{monitor_slug}/", monitor::route(config))
69
70 .route("/api/{project_id}/store/", store::route(config))
71 .route("/api/{project_id}/envelope/", envelope::route(config))
72 .route("/api/{project_id}/security/", security_report::route(config))
73 .route("/api/{project_id}/csp-report/", security_report::route(config))
74 .route("/api/{project_id}/nel/", nel::route(config))
75 .route("/api/{project_id}/minidump", minidump::route(config))
77 .route("/api/{project_id}/minidump/", minidump::route(config))
78 .route("/api/{project_id}/events/{event_id}/attachments/", post(attachments::handle))
79 .route("/api/{project_id}/unreal/{sentry_key}/", unreal::route(config))
80 .route("/api/{project_id}/otlp/v1/traces", otlp_traces::route(config))
85 .route("/api/{project_id}/otlp/v1/traces/", otlp_traces::route(config))
86 .route("/api/{project_id}/otlp/v1/logs", otlp_log::route(config));
87 #[cfg(sentry)]
91 let store_routes = store_routes.route("/api/{project_id}/playstation/", playstation::route(config));
92 let store_routes = store_routes.route_layer(middlewares::cors());
93
94 Router::new().merge(internal_routes)
95 .merge(web_routes)
96 .merge(batch_routes)
97 .merge(store_routes)
98 .fallback(forward::forward)
100}