relay_server/endpoints/
mod.rsmod attachments;
mod batch_metrics;
mod batch_outcomes;
mod common;
mod envelope;
mod events;
mod forward;
mod health_check;
mod minidump;
mod monitor;
mod nel;
mod project_configs;
mod public_keys;
mod security_report;
mod statics;
mod store;
mod traces;
mod unreal;
use axum::extract::DefaultBodyLimit;
use axum::routing::{any, get, post, Router};
use relay_config::Config;
use crate::middlewares;
use crate::service::ServiceState;
const BATCH_JSON_BODY_LIMIT: usize = 50_000_000; #[rustfmt::skip]
pub fn routes(config: &Config) -> Router<ServiceState>{
let internal_routes = Router::new()
.route("/api/relay/healthcheck/:kind/", get(health_check::handle))
.route("/api/relay/events/:event_id/", get(events::handle));
let internal_routes = internal_routes
.route("/api/relay/*not_found", any(statics::not_found));
let web_routes = Router::new()
.route("/api/0/relays/projectconfigs/", post(project_configs::handle))
.route("/api/0/relays/publickeys/", post(public_keys::handle))
.route("/api/0/relays/live/", get(health_check::handle_live))
.route_layer(DefaultBodyLimit::max(crate::constants::MAX_JSON_SIZE));
let batch_routes = Router::new()
.route("/api/0/relays/outcomes/", post(batch_outcomes::handle))
.route("/api/0/relays/metrics/", post(batch_metrics::handle))
.route_layer(DefaultBodyLimit::max(BATCH_JSON_BODY_LIMIT));
let store_routes = Router::new()
.route("/api/store/", store::route(config))
.route("/api/:project_id/cron/:monitor_slug/:sentry_key", monitor::route(config))
.route("/api/:project_id/cron/:monitor_slug/:sentry_key/", monitor::route(config))
.route("/api/:project_id/cron/:monitor_slug", monitor::route(config))
.route("/api/:project_id/cron/:monitor_slug/", monitor::route(config))
.route("/api/:project_id/store/", store::route(config))
.route("/api/:project_id/envelope/", envelope::route(config))
.route("/api/:project_id/security/", security_report::route(config))
.route("/api/:project_id/csp-report/", security_report::route(config))
.route("/api/:project_id/nel/", nel::route(config))
.route("/api/:project_id/minidump", minidump::route(config))
.route("/api/:project_id/minidump/", minidump::route(config))
.route("/api/:project_id/events/:event_id/attachments/", post(attachments::handle))
.route("/api/:project_id/unreal/:sentry_key/", unreal::route(config))
.route("/api/:project_id/otlp/v1/traces/", traces::route(config))
.route_layer(middlewares::cors());
Router::new().merge(internal_routes)
.merge(web_routes)
.merge(batch_routes)
.merge(store_routes)
.fallback(forward::forward)
}