add an endpoint for debugging headers
This commit is contained in:
parent
4203c61a59
commit
babd215e69
@ -158,6 +158,7 @@ pub async fn serve(port: u16, proxy_app: Arc<Web3ProxyApp>) -> anyhow::Result<()
|
||||
//
|
||||
.route("/health", get(status::health))
|
||||
.route("/status", get(status::status))
|
||||
.route("/status/headers", get(status::status_headers))
|
||||
//
|
||||
// User stuff
|
||||
//
|
||||
|
@ -7,6 +7,8 @@ use super::{FrontendHealthCache, FrontendResponseCache, FrontendResponseCaches};
|
||||
use crate::app::{Web3ProxyApp, APP_USER_AGENT};
|
||||
use axum::{http::StatusCode, response::IntoResponse, Extension, Json};
|
||||
use axum_macros::debug_handler;
|
||||
use hashbrown::HashMap;
|
||||
use http::HeaderMap;
|
||||
use serde_json::json;
|
||||
use std::sync::Arc;
|
||||
|
||||
@ -27,6 +29,18 @@ pub async fn health(
|
||||
}
|
||||
}
|
||||
|
||||
#[debug_handler]
|
||||
pub async fn status_headers(headers: HeaderMap) -> impl IntoResponse {
|
||||
let headers: HashMap<Option<String>, String> = headers
|
||||
.into_iter()
|
||||
.map(|(k, v)| (k.map(|k| k.to_string()), format!("{:?}", v)))
|
||||
.collect();
|
||||
|
||||
let body = json!({ "headers": headers });
|
||||
|
||||
Json(body)
|
||||
}
|
||||
|
||||
/// Very basic status page.
|
||||
///
|
||||
/// TODO: replace this with proper stats and monitoring
|
||||
|
Loading…
Reference in New Issue
Block a user