Skip to content

Commit

Permalink
feat: Implement OperationHandler for axum::handler::Layered (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
svix-jplatte authored May 15, 2024
1 parent 372fe86 commit 2bad9ab
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion crates/aide/src/axum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,14 @@ mod private {
pub trait Sealed {}
}

impl<I, O, L, H, T, S> OperationHandler<I, O> for axum::handler::Layered<L, H, T, S>
where
H: OperationHandler<I, O>,
I: OperationInput,
O: OperationOutput,
{
}

/// A trait that extends [`axum::handler::Handler`] with API operation
/// details.
///
Expand All @@ -739,7 +747,7 @@ where
#[allow(clippy::unused_async)]
mod tests {
use crate::axum::{routing, ApiRouter};
use axum::extract::State;
use axum::{extract::State, handler::Handler};

async fn test_handler1(State(_): State<TestState>) {}

Expand Down Expand Up @@ -795,4 +803,12 @@ mod tests {
assert!(item.get.is_some());
assert!(item.post.is_some());
}

#[test]
fn test_layered_handler() {
let _app: ApiRouter = ApiRouter::new().api_route(
"/test-route",
routing::get(test_handler3.layer(tower_layer::Identity::new())),
);
}
}

0 comments on commit 2bad9ab

Please sign in to comment.