Skip to content

Commit

Permalink
add no-cache header to metadata handler (#608)
Browse files Browse the repository at this point in the history
  • Loading branch information
getong authored Feb 21, 2025
1 parent 35187f9 commit 9746df5
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion apps/indexer-proxy/proxy/src/metadata/ai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ use crate::project::Project;
pub async fn metadata(_project: &Project) -> Result<Value> {
Ok(json!({
"ai": "TODO",
"Cache-control": "no-cache",
}))
}
1 change: 0 additions & 1 deletion apps/indexer-proxy/proxy/src/metadata/rpc_evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,5 @@ pub async fn metadata(project: &Project, network: MetricsNetwork) -> Result<Valu
"lastTime": last_time,
"genesis": genesis,
"chainId": chain,
"Cache-control": "no-cache",
}))
}
1 change: 0 additions & 1 deletion apps/indexer-proxy/proxy/src/metadata/rpc_substrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,5 @@ pub async fn metadata(project: &Project, network: MetricsNetwork) -> Result<Valu
"lastTime": Utc::now().timestamp(),
"genesis": genesis,
"chainId": chain,
"Cache-control": "no-cache",
}))
}
1 change: 0 additions & 1 deletion apps/indexer-proxy/proxy/src/metadata/subgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,5 @@ pub async fn metadata(project: &Project, network: MetricsNetwork) -> Result<Valu
"targetHeight": 0,
"chainId": "",
"subqueryHealthy": false,
"Cache-control": "no-cache",
}))
}
1 change: 0 additions & 1 deletion apps/indexer-proxy/proxy/src/metadata/subquery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,5 @@ pub async fn metadata(project: &Project, network: MetricsNetwork) -> Result<Valu
"subqueryHealthy": subquery_healthy,
"subqueryNode": subquery_node,
"subqueryQuery": subquery_query,
"Cache-control": "no-cache",
}))
}
10 changes: 7 additions & 3 deletions apps/indexer-proxy/proxy/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,12 +719,16 @@ fn process_sign(value: &mut serde_json::Map<String, serde_json::Value>, key: &st
}
}

async fn metadata_handler(Path(deployment): Path<String>) -> Result<Json<Value>, Error> {
get_project(&deployment)
async fn metadata_handler(Path(deployment): Path<String>) -> Result<Response<String>, Error> {
let body = get_project(&deployment)
.await?
.metadata(MetricsNetwork::HTTP)
.await
.map(Json)
.map(Json)?;
Ok(build_response(
body.to_string(),
vec![("Cache-control", "no-cache")],
))
}

async fn healthy_handler() -> Result<Json<Value>, Error> {
Expand Down

0 comments on commit 9746df5

Please sign in to comment.