use axum::Json;
use axum::response::{IntoResponse, Response};
use serde_json::Value;
use crate::toon::{self, WireFormat};
pub(crate) fn memories_response(format: WireFormat, payload: Value) -> Response {
match format {
WireFormat::Json => Json(payload).into_response(),
WireFormat::Toon => toon::memories_to_toon(&payload, false).into_response(),
WireFormat::ToonCompact => toon::memories_to_toon(&payload, true).into_response(),
}
}
pub(crate) fn search_response(format: WireFormat, payload: Value) -> Response {
match format {
WireFormat::Json => Json(payload).into_response(),
WireFormat::Toon => toon::search_to_toon(&payload, false).into_response(),
WireFormat::ToonCompact => toon::search_to_toon(&payload, true).into_response(),
}
}
pub(crate) fn invalid_format_response(msg: &str) -> Response {
(
axum::http::StatusCode::BAD_REQUEST,
Json(serde_json::json!({ "error": msg })),
)
.into_response()
}