mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-10 03:09:50 +08:00
54 lines
1.3 KiB
Rust
54 lines
1.3 KiB
Rust
use crate::control::GatewayPublicRequestContext;
|
|||
|
|
use crate::{AppState, GatewayError};
|
||
|
|
use axum::{
|
||
|
|
body::Body,
|
||
|
|
response::{IntoResponse, Response},
|
||
|
|
};
|
||
|
|
|
||
|
|
mod analytics;
|
||
|
|
mod analytics_routes;
|
||
|
|
mod detail_routes;
|
||
|
|
mod helpers;
|
||
|
|
mod replay;
|
||
|
|
mod summary_routes;
|
||
|
|
|
||
|
|
pub(crate) async fn maybe_build_local_admin_usage_response(
|
||
|
|
state: &AppState,
|
||
|
|
request_context: &GatewayPublicRequestContext,
|
||
|
|
request_body: Option<&axum::body::Bytes>,
|
||
|
|
) -> Result<Option<Response<Body>>, GatewayError> {
|
||
|
|
let Some(decision) = request_context.control_decision.as_ref() else {
|
||
|
|
return Ok(None);
|
||
|
|
};
|
||
|
|
|
||
|
|
if decision.route_family.as_deref() != Some("usage_manage") {
|
||
|
|
return Ok(None);
|
||
|
|
}
|
||
|
|
|
||
|
|
if let Some(response) = detail_routes::maybe_build_local_admin_usage_detail_response(
|
||
|
|
state,
|
||
|
|
request_context,
|
||
|
|
request_body,
|
||
|
|
)
|
||
|
|
.await?
|
||
|
|
{
|
||
|
|
return Ok(Some(response));
|
||
|
|
}
|
||
|
|
|
||
|
|
if let Some(response) =
|
||
|
|
summary_routes::maybe_build_local_admin_usage_summary_response(state, request_context)
|
||
|
|
.await?
|
||
|
|
{
|
||
|
|
return Ok(Some(response));
|
||
|
|
}
|
||
|
|
|
||
|
|
if let Some(response) =
|
||
|
|
analytics_routes::maybe_build_local_admin_usage_analytics_response(state, request_context)
|
||
|
|
.await?
|
||
|
|
{
|
||
|
|
return Ok(Some(response));
|
||
|
|
}
|
||
|
|
|
||
|
|
Ok(None)
|
||
|
|
}
|