Added a route to list all languages
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
parent
6e886a7952
commit
5a68c80122
18
src/route.rs
18
src/route.rs
@ -7,7 +7,7 @@ use crate::lib::establish_connection;
|
|||||||
use crate::model::*;
|
use crate::model::*;
|
||||||
|
|
||||||
#[get("/subtitles/list")]
|
#[get("/subtitles/list")]
|
||||||
async fn list_all() -> impl Responder {
|
async fn list_all_subtitles() -> impl Responder {
|
||||||
use crate::schema::films::dsl::*;
|
use crate::schema::films::dsl::*;
|
||||||
use crate::schema::subtitles::dsl::*;
|
use crate::schema::subtitles::dsl::*;
|
||||||
use crate::schema::languages::dsl::*;
|
use crate::schema::languages::dsl::*;
|
||||||
@ -39,6 +39,18 @@ async fn list_all() -> impl Responder {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_routes(config: &mut web::ServiceConfig) {
|
#[get("/languages/list")]
|
||||||
config.service(list_all);
|
async fn list_all_languages() -> impl Responder {
|
||||||
|
use crate::schema::languages::dsl::*;
|
||||||
|
|
||||||
|
let connection = establish_connection().await;
|
||||||
|
let results = languages
|
||||||
|
.load::<Language>(&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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user