From a9cda152745d62655019c19cc6d2586fe8e47e67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Cabrero-Holgueras?= Date: Mon, 23 Mar 2026 09:50:21 +0100 Subject: [PATCH] fix: update Dockerfile Rust version to 1.88 and fix pricing route for axum 0.8 Bump Rust base image from 1.80 to 1.88 (required by edition2024, darling 0.23, serde_with 3.18, time 0.3.47). Update pricing wildcard route syntax from `*model_name` to `{*model_name}` for axum 0.8 compatibility, and strip the leading slash from captured path segments. Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/nilai-api/src/routes/pricing.rs | 14 ++++++++++---- docker/nilai-api.Dockerfile | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/nilai-api/src/routes/pricing.rs b/crates/nilai-api/src/routes/pricing.rs index fef67ca0..d47a766d 100644 --- a/crates/nilai-api/src/routes/pricing.rs +++ b/crates/nilai-api/src/routes/pricing.rs @@ -12,7 +12,7 @@ pub fn router() -> Router { Router::new() .route("/v1/pricing", get(get_all_prices)) .route( - "/v1/pricing/*model_name", + "/v1/pricing/{*model_name}", get(get_price).put(set_price).delete(delete_price), ) } @@ -41,6 +41,8 @@ async fn get_price( State(state): State, Path(model_name): Path, ) -> Result, (StatusCode, Json)> { + let model_name = model_name.strip_prefix('/').unwrap_or(&model_name); + let store = state.pricing_store.as_ref().ok_or_else(|| { ( StatusCode::SERVICE_UNAVAILABLE, @@ -49,7 +51,7 @@ async fn get_price( })?; let price = store - .get_price(&ModelName::new(&model_name)) + .get_price(&ModelName::new(model_name)) .await .map_err(|e| { ( @@ -67,6 +69,8 @@ async fn set_price( headers: HeaderMap, Json(config): Json, ) -> Result, (StatusCode, Json)> { + let model_name = model_name.strip_prefix('/').unwrap_or(&model_name); + // Verify admin token verify_admin_token(&state, &headers)?; @@ -89,7 +93,7 @@ async fn set_price( })?; store - .set_price(&ModelName::new(&model_name), &config) + .set_price(&ModelName::new(model_name), &config) .await .map_err(|e| { ( @@ -106,6 +110,8 @@ async fn delete_price( Path(model_name): Path, headers: HeaderMap, ) -> Result)> { + let model_name = model_name.strip_prefix('/').unwrap_or(&model_name); + verify_admin_token(&state, &headers)?; if model_name == "default" { @@ -123,7 +129,7 @@ async fn delete_price( })?; let existed = store - .delete_price(&ModelName::new(&model_name)) + .delete_price(&ModelName::new(model_name)) .await .map_err(|e| { ( diff --git a/docker/nilai-api.Dockerfile b/docker/nilai-api.Dockerfile index 4a3ce7e8..83ec71b4 100644 --- a/docker/nilai-api.Dockerfile +++ b/docker/nilai-api.Dockerfile @@ -1,5 +1,5 @@ # Stage 1: Build -FROM rust:1.80-bookworm AS builder +FROM rust:1.88-bookworm AS builder WORKDIR /app