allsource-core 0.30.0

High-performance event store core built in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Admin-only heap profile dump. Registered only in `heap-profile` builds.

use crate::infrastructure::{observability::heap::heap_profile_pprof, security::middleware::Admin};
use axum::{
    http::{StatusCode, header},
    response::{IntoResponse, Response},
};

/// GET /api/v1/admin/heap-profile
pub async fn heap_profile(Admin(_): Admin) -> Response {
    match heap_profile_pprof().await {
        Ok(bytes) => ([(header::CONTENT_TYPE, "application/octet-stream")], bytes).into_response(),
        Err(err) => (StatusCode::SERVICE_UNAVAILABLE, err.to_string()).into_response(),
    }
}