From 14854528e06fc0f4db8569da4a0af9280c1446a3 Mon Sep 17 00:00:00 2001 From: rymnc <43716372+rymnc@users.noreply.github.com> Date: Wed, 18 Dec 2024 01:07:45 +0530 Subject: [PATCH] test: more shenanigans with query string --- committer/src/api.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/committer/src/api.rs b/committer/src/api.rs index 20e3fc15..6eca6ee2 100644 --- a/committer/src/api.rs +++ b/committer/src/api.rs @@ -94,12 +94,13 @@ async fn metrics(registry: web::Data>) -> impl Responder { #[serde(rename_all = "lowercase")] enum HeightVariant { Latest, - Height(u32), + Specific, } #[derive(Deserialize)] struct CostQueryParams { variant: HeightVariant, + value: Option, limit: Option, } @@ -112,7 +113,12 @@ async fn costs( let response = match query.variant { HeightVariant::Latest => data.get_latest_costs(limit).await, - HeightVariant::Height(from_height) => data.get_costs(from_height, limit).await, + HeightVariant::Specific => { + let from_height = query + .value + .ok_or_else(|| services::Error::Other("height value is required".to_string()))?; + data.get_costs(from_height, limit).await + } }; match response {