image
This commit is contained in:
parent
6c6ee93fbf
commit
4c0769199c
4 changed files with 48 additions and 10 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue