Skip to content

Commit 6a29e6e

Browse files
committed
refactor: use subgraph client as state
Signed-off-by: Gustavo Inacio <[email protected]>
1 parent 2fc04f7 commit 6a29e6e

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

crates/service/src/routes/static_subgraph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use axum::{body::Bytes, response::IntoResponse, Extension, Json};
4+
use axum::{body::Bytes, extract::State, response::IntoResponse, Json};
55
use reqwest::StatusCode;
66
use serde_json::json;
77
use tracing::warn;
@@ -10,7 +10,7 @@ use indexer_common::SubgraphClient;
1010

1111
#[autometrics::autometrics]
1212
pub async fn static_subgraph_request_handler(
13-
Extension(subgraph_client): Extension<&'static SubgraphClient>,
13+
State(subgraph_client): State<&'static SubgraphClient>,
1414
body: Bytes,
1515
) -> Result<impl IntoResponse, StaticSubgraphError> {
1616
let response = subgraph_client.query_raw(body).await?;

crates/service/src/service/indexer_service.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ impl IndexerService {
414414
"/network",
415415
post(static_subgraph_request_handler)
416416
.route_layer(auth_layer)
417-
.route_layer(Extension(network_subgraph))
417+
.with_state(network_subgraph)
418418
.route_layer(static_subgraph_rate_limiter.clone()),
419419
);
420420
} else {
@@ -428,14 +428,13 @@ impl IndexerService {
428428

429429
let auth_layer = ValidateRequestHeaderLayer::bearer(free_auth_token);
430430

431-
misc_routes = misc_routes
432-
.route(
433-
"/escrow",
434-
post(static_subgraph_request_handler)
435-
.route_layer(auth_layer)
436-
.route_layer(Extension(escrow_subgraph)),
437-
)
438-
.route_layer(static_subgraph_rate_limiter);
431+
misc_routes = misc_routes.route(
432+
"/escrow",
433+
post(static_subgraph_request_handler)
434+
.route_layer(auth_layer)
435+
.with_state(escrow_subgraph)
436+
.route_layer(static_subgraph_rate_limiter),
437+
)
439438
} else {
440439
warn!("`serve_escrow_subgraph` is enabled but no `serve_auth_token` provided. Disabling it.");
441440
}

0 commit comments

Comments
 (0)