Skip to content

Commit

Permalink
fix: error in order for middleware router
Browse files Browse the repository at this point in the history
Signed-off-by: Gustavo Inacio <[email protected]>
  • Loading branch information
gusinacio committed Nov 28, 2024
1 parent 4e05c90 commit 12dc95c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions crates/service/src/service/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,18 @@ impl ServiceRouter {
))
};

let attestation_state = AttestationState {
attestation_signers,
};

let mut handler = post(request_handler);

handler = handler
// create attestation
.route_layer(from_fn(attestation_middleware))
// inject signer
.route_layer(from_fn_with_state(attestation_state, signer_middleware));

// inject auth
let failed_receipt_metric = Box::leak(Box::new(FAILED_RECEIPT.clone()));
let tap_auth = auth::tap_receipt_authorize(tap_manager, failed_receipt_metric);
Expand All @@ -319,9 +329,6 @@ impl ServiceRouter {
escrow_accounts,
domain_separator: self.domain_separator,
};
let attestation_state = AttestationState {
attestation_signers,
};

let service_builder = ServiceBuilder::new()
// inject deployment id
Expand All @@ -340,11 +347,7 @@ impl ServiceRouter {
HANDLER_FAILURE.clone(),
))
// tap context
.layer(from_fn(context_middleware))
// inject signer
.layer(from_fn_with_state(attestation_state, signer_middleware))
// create attestation
.layer(from_fn(attestation_middleware));
.layer(from_fn(context_middleware));

handler.route_layer(service_builder)
};
Expand Down

0 comments on commit 12dc95c

Please sign in to comment.