From 94d716ef9cd655afbd16acdbe90c5bec9b236657 Mon Sep 17 00:00:00 2001 From: Andre Henriques Date: Mon, 10 Jul 2023 14:59:11 +0100 Subject: [PATCH] chore: add get_animation_by_name --- src/animations.rs | 11 +++++++++++ src/main.rs | 1 + 2 files changed, 12 insertions(+) diff --git a/src/animations.rs b/src/animations.rs index 70c49ee..35d1463 100644 --- a/src/animations.rs +++ b/src/animations.rs @@ -362,6 +362,17 @@ pub async fn start_animation( create_message(200, "Started animation") } +#[get("/animation/")] +pub async fn get_animation_by_name(name: &str, db: &State) -> String { + let animation = get_animation_or_string_error(name, db); + if let Err(animation) = animation { + return animation; + } + let animation = animation.unwrap(); + + json!(animation).to_string() +} + /** * * Clear animations diff --git a/src/main.rs b/src/main.rs index 2427be9..8f99701 100644 --- a/src/main.rs +++ b/src/main.rs @@ -233,6 +233,7 @@ async fn main() -> GResult { animations::get_animation_request, animations::toggle_animation, animations::get_animations, + animations::get_animation_by_name, ], ) .manage(conn_pool_arc.clone())