Implement the video adapter to retrieve the root folder content.

This commit is contained in:
Florian THIERRY
2026-07-14 21:35:55 +02:00
parent fc7eeb1d57
commit beb0134dfc
11 changed files with 90 additions and 29 deletions
+21 -1
View File
@@ -1,7 +1,12 @@
use actix_web::{get, HttpResponse, Responder};
use std::sync::Arc;
use actix_web::{get, web, HttpResponse, Responder};
use tokio::fs::File;
use tokio_util::codec::{BytesCodec, FramedRead};
use futures_util::stream::StreamExt;
use lumiere_application::video::service::VideoService;
use lumiere_domain::video::error::VideoError;
use lumiere_domain::video::model::library_item::LibraryItem;
use crate::video::model::LibraryItemDto;
#[get("/download")]
pub async fn download_file() -> impl Responder {
@@ -14,4 +19,19 @@ pub async fn download_file() -> impl Responder {
yield chunk.map(|bytes| bytes.freeze());
}
})
}
#[get("/library")]
pub async fn get_root_folder_content(
video_service: web::Data<Arc<VideoService>>
) -> impl Responder {
match video_service.list_root_folder() {
Ok(library_items) => {
let result: Vec<LibraryItemDto> = library_items.iter()
.map(LibraryItemDto::new)
.collect();
HttpResponse::Ok().json(result)
}
Err(_) => HttpResponse::InternalServerError().finish()
}
}