From 33452cd194d06e792c60ccfa8cca9049933c283c Mon Sep 17 00:00:00 2001 From: Dan Alekseev Date: Fri, 12 Apr 2024 17:36:37 +0400 Subject: [PATCH] fix: from_request_parts should be before body --- axum-htmx-derive/src/boosted_by/boosted_by.rs | 2 +- axum-htmx-derive/src/boosted_by/tests.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/axum-htmx-derive/src/boosted_by/boosted_by.rs b/axum-htmx-derive/src/boosted_by/boosted_by.rs index 169625a..88b2032 100644 --- a/axum-htmx-derive/src/boosted_by/boosted_by.rs +++ b/axum-htmx-derive/src/boosted_by/boosted_by.rs @@ -73,7 +73,7 @@ pub fn transform_using_template(input: MacroInput, template_fn: ItemFn) -> ItemF // add HxBoosted input to source_fn let hx_boosted_input = template_fn.sig.inputs.first().unwrap().clone(); - source_fn.sig.inputs.push(hx_boosted_input); + source_fn.sig.inputs.insert(0, hx_boosted_input); // pop the last statement and wrap it with if-else let source_stmt = source_fn.block.stmts.pop().unwrap(); diff --git a/axum-htmx-derive/src/boosted_by/tests.rs b/axum-htmx-derive/src/boosted_by/tests.rs index 5fc5e45..0a7c839 100644 --- a/axum-htmx-derive/src/boosted_by/tests.rs +++ b/axum-htmx-derive/src/boosted_by/tests.rs @@ -17,7 +17,7 @@ fn boosted_by() { } }; let expected = quote! { - async fn index(Path(user_id): Path, axum_htmx::HxBoosted(boosted): axum_htmx::HxBoosted) -> Html { + async fn index(axum_htmx::HxBoosted(boosted): axum_htmx::HxBoosted, Path(user_id): Path) -> Html { let ctx = HomeTemplate { locale: "en".to_string(), };