Skip to content

Commit dfda7f1

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

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

common/src/indexer_service/http/request_handler.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub async fn request_handler<I>(
5454
typed_header: TypedHeader<TapReceipt>,
5555
state: State<Arc<IndexerServiceState<I>>>,
5656
headers: HeaderMap,
57-
body: Bytes,
57+
body: &str,
5858
) -> Result<impl IntoResponse, IndexerServiceError<I::Error>>
5959
where
6060
I: IndexerServiceImpl + Sync + Send + 'static,
@@ -73,15 +73,15 @@ async fn _request_handler<I>(
7373
TypedHeader(receipt): TypedHeader<TapReceipt>,
7474
State(state): State<Arc<IndexerServiceState<I>>>,
7575
headers: HeaderMap,
76-
body: Bytes,
76+
body: &str,
7777
) -> Result<impl IntoResponse, IndexerServiceError<I::Error>>
7878
where
7979
I: IndexerServiceImpl + Sync + Send + 'static,
8080
{
8181
trace!("Handling request for deployment `{manifest_id}`");
8282

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

8686
let Some(receipt) = receipt.into_signed_receipt() else {
8787
// Serve free query, NO METRICS
@@ -178,17 +178,14 @@ where
178178
.await
179179
.map_err(IndexerServiceError::ProcessingError)?;
180180

181-
let req =
182-
std::str::from_utf8(&body).map_err(|_| IndexerServiceError::FailedToSignAttestation)?;
183-
184181
let res = response
185182
.as_str()
186183
.map_err(|_| IndexerServiceError::FailedToSignAttestation)?;
187184

188185
let attestation = AttestationOutput::Attestation(
189186
response
190187
.is_attestable()
191-
.then(|| signer.create_attestation(req, res)),
188+
.then(|| signer.create_attestation(body, res)),
192189
);
193190

194191
let response = response.finalize(attestation);

0 commit comments

Comments
 (0)