Skip to content

Commit

Permalink
Update Poem
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Dec 4, 2024
1 parent e3fa207 commit 5bf85cc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
5 changes: 3 additions & 2 deletions engine/src/routes/items/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
36 changes: 24 additions & 12 deletions engine/src/routes/media/mod.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -57,7 +61,7 @@ impl MediaApi {
}

/// /media
///
///
/// Create a new Media
#[oai(path = "/media", method = "post", tag = "ApiTags::Media")]
async fn create_media(
Expand Down Expand Up @@ -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(
Expand All @@ -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<AppState>>,
media_id: Path<i32>,
) -> Result<Json<Vec<LinkedItem>>> {
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(
Expand Down

0 comments on commit 5bf85cc

Please sign in to comment.