fix: remove Host extractor and update content_url format

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-29 11:48:55 -03:00
parent aa00bb134b
commit 713f33ad87

View File

@@ -1,8 +1,7 @@
use axum::{
extract::{Path, Query, State, Host},
http::{StatusCode},
extract::{Path, Query, State},
http::{StatusCode, header},
response::{Json, Response},
http::header,
};
use log::{debug, warn};
use std::collections::HashMap;
@@ -581,7 +580,6 @@ async fn stream_item_content_response_with_metadata(
)]
pub async fn handle_get_item_latest_meta(
State(state): State<AppState>,
Host(host): Host,
Query(params): Query<TagsQuery>,
) -> Result<Json<ApiResponse<HashMap<String, String>>>, StatusCode> {
let tags: Vec<String> = params
@@ -603,7 +601,7 @@ pub async fn handle_get_item_latest_meta(
let mut item_meta = item_with_meta.meta_as_map();
// Add content_url to metadata
if let Some(item_id) = item_with_meta.item.id {
item_meta.insert("content_url".to_string(), format!("http://{}/api/item/{}/content", host, item_id));
item_meta.insert("content_url".to_string(), format!("/api/item/{}/content", item_id));
}
let response = ApiResponse {
@@ -645,7 +643,6 @@ pub async fn handle_get_item_latest_meta(
)]
pub async fn handle_get_item_meta(
State(state): State<AppState>,
Host(host): Host,
Path(item_id): Path<i64>,
) -> Result<Json<ApiResponse<HashMap<String, String>>>, StatusCode> {
let item_service = AsyncItemService::new(
@@ -660,7 +657,7 @@ pub async fn handle_get_item_meta(
Ok(item_with_meta) => {
let mut item_meta = item_with_meta.meta_as_map();
// Add content_url to metadata
item_meta.insert("content_url".to_string(), format!("http://{}/api/item/{}/content", host, item_id));
item_meta.insert("content_url".to_string(), format!("/api/item/{}/content", item_id));
let response = ApiResponse {
success: true,