diff --git a/src/route.rs b/src/route.rs index f9afac0..6cd53d3 100644 --- a/src/route.rs +++ b/src/route.rs @@ -7,7 +7,7 @@ use crate::lib::establish_connection; use crate::model::*; #[get("/subtitles/list")] -async fn list_all() -> impl Responder { +async fn list_all_subtitles() -> impl Responder { use crate::schema::films::dsl::*; use crate::schema::subtitles::dsl::*; use crate::schema::languages::dsl::*; @@ -39,6 +39,18 @@ async fn list_all() -> impl Responder { }) } -pub fn init_routes(config: &mut web::ServiceConfig) { - config.service(list_all); +#[get("/languages/list")] +async fn list_all_languages() -> impl Responder { + use crate::schema::languages::dsl::*; + + let connection = establish_connection().await; + let results = languages + .load::(&connection).expect("Error loading languages"); + + HttpResponse::Ok().json(results) +} + +pub fn init_routes(config: &mut web::ServiceConfig) { + config.service(list_all_subtitles); + config.service(list_all_languages); }