This commit is contained in:
JMARyA 2024-10-18 10:57:38 +02:00
parent 6c6ee93fbf
commit 4c0769199c
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
4 changed files with 48 additions and 10 deletions

View file

@ -9,6 +9,7 @@ use std::str::FromStr;
pub use demand::*;
pub use error::*;
pub use location::*;
use rocket::fs::NamedFile;
use rocket::post;
use rocket::serde::json::Json;
use serde::Deserialize;
@ -62,6 +63,17 @@ pub fn item_route(
Ok(item.api_json())
}
#[get("/item/<item_id>/image")]
pub async fn item_image_route(item_id: &str, itemdb: &State<ItemDB>) -> Option<NamedFile> {
let item = itemdb.get_item(item_id)?;
if let Some(img_path) = &item.image_path {
return Some(NamedFile::open(img_path).await.ok()?);
}
None
}
/// Returns all variants of an Item
#[get("/item/<item_id>/variants")]
pub fn item_variants_page(