Skip to content

Commit 54e30c4

Browse files
committed
refactor: use &str instead of Bytes
Signed-off-by: Gustavo Inacio <[email protected]>
1 parent 40fe231 commit 54e30c4

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

common/src/indexer_service/http/request_handler.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use std::sync::Arc;
55

66
use axum::{
7-
body::Bytes,
87
extract::{Path, State},
98
http::HeaderMap,
109
response::IntoResponse,
@@ -54,7 +53,7 @@ pub async fn request_handler<I>(
5453
typed_header: TypedHeader<TapReceipt>,
5554
state: State<Arc<IndexerServiceState<I>>>,
5655
headers: HeaderMap,
57-
body: Bytes,
56+
body: String,
5857
) -> Result<impl IntoResponse, IndexerServiceError<I::Error>>
5958
where
6059
I: IndexerServiceImpl + Sync + Send + 'static,
@@ -73,15 +72,15 @@ async fn _request_handler<I>(
7372
TypedHeader(receipt): TypedHeader<TapReceipt>,
7473
State(state): State<Arc<IndexerServiceState<I>>>,
7574
headers: HeaderMap,
76-
body: Bytes,
75+
req: String,
7776
) -> Result<impl IntoResponse, IndexerServiceError<I::Error>>
7877
where
7978
I: IndexerServiceImpl + Sync + Send + 'static,
8079
{
8180
trace!("Handling request for deployment `{manifest_id}`");
8281

8382
let request: QueryBody =
84-
serde_json::from_slice(&body).map_err(|e| IndexerServiceError::InvalidRequest(e.into()))?;
83+
serde_json::from_str(&req).map_err(|e| IndexerServiceError::InvalidRequest(e.into()))?;
8584

8685
let Some(receipt) = receipt.into_signed_receipt() else {
8786
// Serve free query, NO METRICS
@@ -178,17 +177,14 @@ where
178177
.await
179178
.map_err(IndexerServiceError::ProcessingError)?;
180179

181-
let req =
182-
std::str::from_utf8(&body).map_err(|_| IndexerServiceError::FailedToSignAttestation)?;
183-
184180
let res = response
185181
.as_str()
186182
.map_err(|_| IndexerServiceError::FailedToSignAttestation)?;
187183

188184
let attestation = AttestationOutput::Attestation(
189185
response
190186
.is_attestable()
191-
.then(|| signer.create_attestation(req, res)),
187+
.then(|| signer.create_attestation(&req, res)),
192188
);
193189

194190
let response = response.finalize(attestation);

0 commit comments

Comments
 (0)