use axum::{extract::{Path, State}, http::{header, HeaderMap, HeaderValue, StatusCode}, response::{Html, IntoResponse}}; use kernel::repositories::users::get_user_asset_by_id; use crate::AppState; pub async fn get_user_asset( State(app_state): State, Path(asset_id): Path ) -> impl IntoResponse { let user_asset = match get_user_asset_by_id(&app_state.db, &asset_id).await { Err(_) => { return ( StatusCode::NOT_FOUND, Html("Could not find user asset") ).into_response(); }, Ok(ua) => ua }; let mut hm = HeaderMap::new(); hm.insert( header::CONTENT_TYPE, HeaderValue::from_str(&user_asset.mime_type).expect("Constructing header value.") ); (hm, user_asset.content).into_response() }