Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
novacrazy committed Sep 17, 2024
1 parent 3d1c727 commit d9a5fa7
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/api/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,25 +569,19 @@ macro_rules! command {
{
type Rejection = Response;

#[allow(unused_variables, non_snake_case)]
#[allow(unused_variables)]
fn from_request(req: Request, state: &S) -> impl std::future::Future<Output = Result<Self, Self::Rejection>> + Send {
async move {
let (mut parts, body) = req.into_parts();

let Path(($($field_name,)*)) = Path::<($(segments::[<$field_name:camel>],)*)>::from_request_parts(&mut parts, state)
.await.map_err(IntoResponse::into_response)?;

$(
use ftl::extract::one_of::{OneOfAny, OneOf};

let OneOf($body_name) = OneOfAny::from_request(Request::from_parts(parts, body), state)
.await.map_err(IntoResponse::into_response)?;
)?

Ok($name {
$($field_name,)*

$( body: $body_name, )?
$(body: ftl::extract::one_of::OneOfAny::<$body_name>::from_request(Request::from_parts(parts, body), state)
.await.map_err(IntoResponse::into_response)?.0)?
})
}
}
Expand Down

0 comments on commit d9a5fa7

Please sign in to comment.