From 9684d184826e86c88f45cab72397c5186b8ec494 Mon Sep 17 00:00:00 2001 From: Buck Doyle Date: Mon, 23 Oct 2023 22:32:37 -0400 Subject: [PATCH] ud: Add Axum debug handlers --- unmnemonic_devices_vrs/Cargo.lock | 13 +++++++++++++ unmnemonic_devices_vrs/Cargo.toml | 1 + unmnemonic_devices_vrs/src/routes/calls.rs | 2 ++ unmnemonic_devices_vrs/src/routes/conferences.rs | 1 + unmnemonic_devices_vrs/src/routes/meetings.rs | 2 ++ unmnemonic_devices_vrs/src/routes/recordings.rs | 6 ++++++ unmnemonic_devices_vrs/src/routes/root.rs | 2 ++ unmnemonic_devices_vrs/src/routes/teams.rs | 6 ++++++ unmnemonic_devices_vrs/src/routes/util.rs | 1 + 9 files changed, 34 insertions(+) diff --git a/unmnemonic_devices_vrs/Cargo.lock b/unmnemonic_devices_vrs/Cargo.lock index 0706cbd9..32c6ba9c 100644 --- a/unmnemonic_devices_vrs/Cargo.lock +++ b/unmnemonic_devices_vrs/Cargo.lock @@ -133,6 +133,18 @@ dependencies = [ "tower-service", ] +[[package]] +name = "axum-macros" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdca6a10ecad987bda04e95606ef85a5417dcaac1a78455242d72e031e2b6b62" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.7", +] + [[package]] name = "axum-template" version = "0.15.1" @@ -2683,6 +2695,7 @@ name = "unmnemonic_devices_vrs" version = "0.1.0" dependencies = [ "axum", + "axum-macros", "axum-template", "base64 0.21.4", "chrono", diff --git a/unmnemonic_devices_vrs/Cargo.toml b/unmnemonic_devices_vrs/Cargo.toml index bf506517..5a7d9b38 100644 --- a/unmnemonic_devices_vrs/Cargo.toml +++ b/unmnemonic_devices_vrs/Cargo.toml @@ -36,6 +36,7 @@ sqlx = { version = "0.7.0-alpha.2", features = [ ] } urlencoding = "2.1.2" base64 = "0.21.4" +axum-macros = "0.3.8" [dependencies.uuid] version = "1.3.1" diff --git a/unmnemonic_devices_vrs/src/routes/calls.rs b/unmnemonic_devices_vrs/src/routes/calls.rs index cc3a0eb4..7985a3fb 100644 --- a/unmnemonic_devices_vrs/src/routes/calls.rs +++ b/unmnemonic_devices_vrs/src/routes/calls.rs @@ -30,6 +30,7 @@ pub struct Call { start: String, } +#[axum_macros::debug_handler] pub async fn get_calls(Key(key): Key, State(state): State) -> impl IntoResponse { let env_config_provider = EnvVarProvider::new(env::vars().collect()); let config = &env_config_provider.get_config(); @@ -89,6 +90,7 @@ pub struct CreateCallParams { to: String, } +#[axum_macros::debug_handler] pub async fn post_calls( State(state): State, Form(params): Form, diff --git a/unmnemonic_devices_vrs/src/routes/conferences.rs b/unmnemonic_devices_vrs/src/routes/conferences.rs index ca4a761c..f429b76d 100644 --- a/unmnemonic_devices_vrs/src/routes/conferences.rs +++ b/unmnemonic_devices_vrs/src/routes/conferences.rs @@ -13,6 +13,7 @@ pub struct Conference { sid: String, } +#[axum_macros::debug_handler] pub async fn get_conference( Key(key): Key, Path(sid): Path, diff --git a/unmnemonic_devices_vrs/src/routes/meetings.rs b/unmnemonic_devices_vrs/src/routes/meetings.rs index c38a69d3..16363e05 100644 --- a/unmnemonic_devices_vrs/src/routes/meetings.rs +++ b/unmnemonic_devices_vrs/src/routes/meetings.rs @@ -21,6 +21,7 @@ pub struct MeetingTemplate { description: String, } +#[axum_macros::debug_handler] pub async fn get_meeting( Key(key): Key, Path(id): Path, @@ -56,6 +57,7 @@ pub async fn get_meeting( ) } +#[axum_macros::debug_handler] pub async fn post_meeting(Path(id): Path, Form(form): Form) -> Redirect { match form.speech_result.as_str() { "Record." => Redirect::to("/voicemails/fixme"), diff --git a/unmnemonic_devices_vrs/src/routes/recordings.rs b/unmnemonic_devices_vrs/src/routes/recordings.rs index ebad7fb0..304b4ff6 100644 --- a/unmnemonic_devices_vrs/src/routes/recordings.rs +++ b/unmnemonic_devices_vrs/src/routes/recordings.rs @@ -17,6 +17,7 @@ pub struct CharacterPrompts { add_unrecorded: bool, } +#[axum_macros::debug_handler] pub async fn get_character_prompts( Key(key): Key, Path(character_name): Path, @@ -61,6 +62,7 @@ pub struct UnrecordedIntroduction { redirect: String, } +#[axum_macros::debug_handler] pub async fn post_character_prompts( State(state): State, Path(character_name): Path, @@ -102,6 +104,7 @@ pub async fn post_character_prompts( } } +#[axum_macros::debug_handler] pub async fn get_unrecorded_character_prompt( State(state): State, Path(character_name): Path, @@ -159,6 +162,7 @@ pub struct MaybeRecordingParams { unrecorded: Option, } +#[axum_macros::debug_handler] pub async fn get_character_prompt( Key(key): Key, Path((character_name, prompt_name)): Path<(String, String)>, @@ -197,6 +201,7 @@ pub struct ConfirmRecordingPrompt { action: String, } +#[axum_macros::debug_handler] pub async fn post_character_prompt( Key(_key): Key, Path((character_name, prompt_name)): Path<(String, String)>, @@ -231,6 +236,7 @@ pub struct DecideParams { unrecorded: Option, } +#[axum_macros::debug_handler] pub async fn post_character_prompt_decide( Key(_key): Key, Path((character_name, prompt_name)): Path<(String, String)>, diff --git a/unmnemonic_devices_vrs/src/routes/root.rs b/unmnemonic_devices_vrs/src/routes/root.rs index 959f7035..2a89629d 100644 --- a/unmnemonic_devices_vrs/src/routes/root.rs +++ b/unmnemonic_devices_vrs/src/routes/root.rs @@ -26,6 +26,7 @@ pub struct RootData { ending: bool, } +#[axum_macros::debug_handler] pub async fn get_root( Key(key): Key, State(state): State, @@ -49,6 +50,7 @@ pub async fn get_root( ) } +#[axum_macros::debug_handler] pub async fn post_root(Form(form): Form) -> Redirect { if form.speech_result == "Begun." { Redirect::to("/?begun") diff --git a/unmnemonic_devices_vrs/src/routes/teams.rs b/unmnemonic_devices_vrs/src/routes/teams.rs index 04ddd601..87da9983 100644 --- a/unmnemonic_devices_vrs/src/routes/teams.rs +++ b/unmnemonic_devices_vrs/src/routes/teams.rs @@ -22,6 +22,7 @@ pub struct Team { excerpts: Option>, } +#[axum_macros::debug_handler] pub async fn get_teams(Key(key): Key, State(state): State) -> impl IntoResponse { let teams = sqlx::query_as::<_, Team>("SELECT *, ARRAY[]::VARCHAR[] AS excerpts FROM teams") .fetch_all(&state.db) @@ -31,6 +32,7 @@ pub async fn get_teams(Key(key): Key, State(state): State) -> impl Int RenderXml(key, state.engine, state.serialised_prompts, Teams { teams }) } +#[axum_macros::debug_handler] pub async fn post_teams( State(state): State, Form(form): Form, @@ -65,6 +67,7 @@ pub struct TeamVoicepass { voicepass: String, } +#[axum_macros::debug_handler] pub async fn get_confirm_team( Key(key): Key, Path(id): Path, @@ -96,6 +99,7 @@ pub async fn get_confirm_team( } } +#[axum_macros::debug_handler] pub async fn post_confirm_team(Path(id): Path, Form(form): Form) -> Redirect { if form.speech_result == "Yes." { Redirect::to(&format!("/teams/{}", id)) @@ -104,6 +108,7 @@ pub async fn post_confirm_team(Path(id): Path, Form(form): Form, @@ -144,6 +149,7 @@ pub struct MeetingNotFound { team_id: Uuid, } +#[axum_macros::debug_handler] pub async fn post_team( State(state): State, Path(id): Path, diff --git a/unmnemonic_devices_vrs/src/routes/util.rs b/unmnemonic_devices_vrs/src/routes/util.rs index 2e9df220..ae4392ad 100644 --- a/unmnemonic_devices_vrs/src/routes/util.rs +++ b/unmnemonic_devices_vrs/src/routes/util.rs @@ -3,6 +3,7 @@ use axum_template::Key; use crate::{render_xml::RenderXml, AppState}; +#[axum_macros::debug_handler] pub async fn get_hangup(Key(key): Key, State(state): State) -> impl IntoResponse { RenderXml(key, state.engine, state.serialised_prompts, ()) }