Skip to content

Commit

Permalink
fix(core): do not construct request if it is already available (#3826)
Browse files Browse the repository at this point in the history
  • Loading branch information
Narayanbhat166 authored Feb 26, 2024
1 parent 2185cd3 commit 84d91a7
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions crates/router/src/services/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,30 +338,31 @@ where
],
);

let connector_request = connector_request.or(connector_integration
.build_request(req, &state.conf.connectors)
.map_err(|error| {
if matches!(
error.current_context(),
&errors::ConnectorError::RequestEncodingFailed
| &errors::ConnectorError::RequestEncodingFailedWithReason(_)
) {
metrics::REQUEST_BUILD_FAILURE.add(
&metrics::CONTEXT,
1,
&[metrics::request::add_attributes(
"connector",
req.connector.to_string(),
)],
)
}
error
})?);
let connector_request = match connector_request {
Some(connector_request) => Some(connector_request),
None => connector_integration
.build_request(req, &state.conf.connectors)
.map_err(|error| {
if matches!(
error.current_context(),
&errors::ConnectorError::RequestEncodingFailed
| &errors::ConnectorError::RequestEncodingFailedWithReason(_)
) {
metrics::REQUEST_BUILD_FAILURE.add(
&metrics::CONTEXT,
1,
&[metrics::request::add_attributes(
"connector",
req.connector.to_string(),
)],
)
}
error
})?,
};

match connector_request {
Some(request) => {
logger::debug!(connector_request=?request);

let masked_request_body = match &request.body {
Some(request) => match request {
RequestContent::Json(i)
Expand Down Expand Up @@ -1828,7 +1829,7 @@ pub fn build_redirection_form(
threeDSsecureInterface.on('challenge', function(e) {{
console.log('Challenged');
document.getElementById('loader-wrapper').style.display = 'none';
document.getElementById('loader-wrapper').style.display = 'none';
}});
threeDSsecureInterface.on('complete', function(e) {{
Expand Down

0 comments on commit 84d91a7

Please sign in to comment.