feat: enhance HTTP logging and API responses with content metadata
Co-authored-by: aider (openai/andrew/openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
@@ -58,6 +58,14 @@ pub struct ItemInfo {
|
||||
pub metadata: HashMap<String, String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, ToSchema)]
|
||||
pub struct ItemContentInfo {
|
||||
#[serde(flatten)]
|
||||
pub metadata: HashMap<String, String>,
|
||||
pub content: Option<String>,
|
||||
pub binary: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct TagsQuery {
|
||||
pub tags: Option<String>,
|
||||
@@ -111,12 +119,17 @@ pub async fn logging_middleware(
|
||||
) -> Response {
|
||||
let method = request.method().clone();
|
||||
let uri = request.uri().clone();
|
||||
let content_length = request.headers()
|
||||
.get("content-length")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.and_then(|s| s.parse::<u64>().ok())
|
||||
.unwrap_or(0);
|
||||
|
||||
let start = Instant::now();
|
||||
let response = next.run(request).await;
|
||||
let duration = start.elapsed();
|
||||
|
||||
info!("{} {} {} {} - {:?}", addr, method, uri, response.status(), duration);
|
||||
info!("{} {} {} {} {} bytes - {:?}", addr, method, uri, response.status(), content_length, duration);
|
||||
|
||||
response
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user