relay_server/endpoints/
mod.rs1mod attachments;
7mod autoscaling;
8mod batch_metrics;
9mod batch_outcomes;
10mod common;
11mod envelope;
12mod forward;
13mod health_check;
14mod integrations;
15mod minidump;
16mod monitor;
17mod nel;
18#[cfg(sentry)]
19mod playstation;
20mod project_configs;
21mod public_keys;
22mod security_report;
23mod statics;
24mod store;
25mod unreal;
26
27use axum::extract::DefaultBodyLimit;
28use axum::routing::{Router, any, get, post};
29use relay_config::Config;
30
31use crate::middlewares;
32use crate::service::ServiceState;
33
34const BATCH_JSON_BODY_LIMIT: usize = 50_000_000; pub fn all_routes(config: &Config) -> Router<ServiceState> {
41 public_routes_raw(config).merge(internal_routes(config))
42}
43
44#[rustfmt::skip]
48pub fn internal_routes(_: &Config) -> Router<ServiceState>{
49 Router::new()
50 .route("/api/relay/healthcheck/{kind}/", get(health_check::handle))
51 .route("/api/relay/autoscaling/", get(autoscaling::handle))
52 .route("/api/relay/{*not_found}", any(statics::not_found))
54}
55
56pub fn public_routes(config: &Config) -> Router<ServiceState> {
60 public_routes_raw(config).route("/api/relay/{*not_found}", any(statics::not_found))
62}
63
64#[rustfmt::skip]
65fn public_routes_raw(config: &Config) -> Router<ServiceState> {
66 let web_routes = Router::new()
68 .route("/api/0/relays/projectconfigs/", post(project_configs::handle))
69 .route("/api/0/relays/publickeys/", post(public_keys::handle))
70 .route("/api/0/relays/live/", get(health_check::handle_live))
72 .route_layer(DefaultBodyLimit::max(crate::constants::MAX_JSON_SIZE));
73
74 let batch_routes = Router::new()
75 .route("/api/0/relays/outcomes/", post(batch_outcomes::handle))
76 .route("/api/0/relays/metrics/", post(batch_metrics::handle))
77 .route_layer(DefaultBodyLimit::max(BATCH_JSON_BODY_LIMIT));
78
79 let store_routes = Router::new()
81 .route("/api/store/", store::route(config))
83 .route("/api/{project_id}/cron/{monitor_slug}/{sentry_key}", monitor::route(config))
85 .route("/api/{project_id}/cron/{monitor_slug}/{sentry_key}/", monitor::route(config))
86 .route("/api/{project_id}/cron/{monitor_slug}", monitor::route(config))
87 .route("/api/{project_id}/cron/{monitor_slug}/", monitor::route(config))
88
89 .route("/api/{project_id}/store/", store::route(config))
90 .route("/api/{project_id}/envelope/", envelope::route(config))
91 .route("/api/{project_id}/security/", security_report::route(config))
92 .route("/api/{project_id}/csp-report/", security_report::route(config))
93 .route("/api/{project_id}/nel/", nel::route(config))
94 .route("/api/{project_id}/minidump", minidump::route(config))
96 .route("/api/{project_id}/minidump/", minidump::route(config))
97 .route("/api/{project_id}/events/{event_id}/attachments/", post(attachments::handle))
98 .route("/api/{project_id}/unreal/{sentry_key}/", unreal::route(config));
99
100 #[cfg(sentry)]
101 let store_routes = store_routes.route("/api/{project_id}/playstation/", playstation::route(config));
102 let store_routes = store_routes.route_layer(middlewares::cors());
103
104 let integration_routes = Router::new()
109 .nest("/api/{project_id}/integration/otlp", integrations::otlp::routes(config))
110 .nest("/api/{project_id}/integration/vercel", integrations::vercel::routes(config))
111 .route_layer(middlewares::cors());
112
113 Router::new()
117 .merge(web_routes)
118 .merge(batch_routes)
119 .merge(store_routes)
120 .merge(integration_routes)
121 .fallback(forward::forward)
123}