From 5bf85cc89041b018f514e92e1e4aecd28d20a481 Mon Sep 17 00:00:00 2001 From: Luc Date: Wed, 4 Dec 2024 15:51:49 +0100 Subject: [PATCH] Update Poem --- engine/src/routes/items/mod.rs | 5 +++-- engine/src/routes/media/mod.rs | 36 ++++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/engine/src/routes/items/mod.rs b/engine/src/routes/items/mod.rs index 751c2db..6ebeaa1 100644 --- a/engine/src/routes/items/mod.rs +++ b/engine/src/routes/items/mod.rs @@ -1,9 +1,10 @@ use std::sync::Arc; use poem::{ - web::Data, Result + web::{Data, Query}, + Result, }; -use poem_openapi::{param::{Path, Query}, payload::Json, Object, OpenApi}; +use poem_openapi::{param::Path, payload::Json, Object, OpenApi}; use reqwest::StatusCode; use serde::{Deserialize, Serialize}; use tracing::info; diff --git a/engine/src/routes/media/mod.rs b/engine/src/routes/media/mod.rs index 55384fe..c07aa1a 100644 --- a/engine/src/routes/media/mod.rs +++ b/engine/src/routes/media/mod.rs @@ -1,15 +1,19 @@ use std::sync::Arc; use poem::{ - web::{Data, Multipart}, + web::{Data, Multipart, Query}, Result, }; -use poem_openapi::{param::{Path, Query}, payload::Json, Object, OpenApi}; +use poem_openapi::{param::Path, payload::Json, Object, OpenApi}; use reqwest::StatusCode; use serde::{Deserialize, Serialize}; use super::ApiTags; -use crate::{auth::middleware::AuthToken, models::media::{LinkedItem, Media}, state::AppState}; +use crate::{ + auth::middleware::AuthToken, + models::media::{LinkedItem, Media}, + state::AppState, +}; pub struct MediaApi; @@ -27,7 +31,7 @@ pub struct CreateMediaRequest { #[OpenApi] impl MediaApi { /// /media - /// + /// /// Get all media #[oai(path = "/media", method = "get", tag = "ApiTags::Media")] async fn get_all_media( @@ -42,7 +46,7 @@ impl MediaApi { } /// /media/unassigned - /// + /// /// Get all unassigned media #[oai(path = "/media/unassigned", method = "get", tag = "ApiTags::Media")] async fn get_unassigned_media( @@ -57,7 +61,7 @@ impl MediaApi { } /// /media - /// + /// /// Create a new Media #[oai(path = "/media", method = "post", tag = "ApiTags::Media")] async fn create_media( @@ -86,9 +90,9 @@ impl MediaApi { .unwrap(), ) } - + /// /media/:media_id - /// + /// /// Get a Media by `media_id` #[oai(path = "/media/:media_id", method = "get", tag = "ApiTags::Media")] async fn get_media( @@ -107,19 +111,27 @@ impl MediaApi { } /// /media/:media_id/items - /// + /// /// Get all items linked to a media by `media_id` - #[oai(path = "/media/:media_id/items", method = "get", tag = "ApiTags::Media")] + #[oai( + path = "/media/:media_id/items", + method = "get", + tag = "ApiTags::Media" + )] async fn get_linked_items( &self, state: Data<&Arc>, media_id: Path, ) -> Result>> { - Ok(Json(Media::get_linked_items(&state.database, media_id.0).await.unwrap())) + Ok(Json( + Media::get_linked_items(&state.database, media_id.0) + .await + .unwrap(), + )) } /// /media/:media_id - /// + /// /// Delete a Media by `media_id` #[oai(path = "/media/:media_id", method = "delete", tag = "ApiTags::Media")] async fn delete_media(