From 19871c1924a8569df741d4bf5f63943b6b646c16 Mon Sep 17 00:00:00 2001 From: rtkay123 Date: Thu, 14 Aug 2025 18:33:10 +0200 Subject: feat(config): rule http --- .../src/server/http_svc/routes/rule/update.rs | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 crates/configuration/src/server/http_svc/routes/rule/update.rs (limited to 'crates/configuration/src/server/http_svc/routes/rule/update.rs') diff --git a/crates/configuration/src/server/http_svc/routes/rule/update.rs b/crates/configuration/src/server/http_svc/routes/rule/update.rs new file mode 100644 index 0000000..7bf3fe0 --- /dev/null +++ b/crates/configuration/src/server/http_svc/routes/rule/update.rs @@ -0,0 +1,45 @@ +use axum::extract::State; +use tonic::IntoRequest; +use warden_core::configuration::rule::{ + RuleConfiguration, UpdateRuleRequest, mutate_rule_configuration_server::MutateRuleConfiguration, +}; + +use crate::{ + server::{error::AppError, http_svc::TAG_RULES, version::Version}, + state::AppHandle, +}; + +/// Update the routing configuration +#[utoipa::path( + put, + path = "/{version}/rule", + params( + ("version" = Version, Path, description = "API version, e.g., v1, v2, v3"), + ), + responses(( + status = OK, + body = RuleConfiguration + )), + operation_id = "update rule configuration", // https://github.com/juhaku/utoipa/issues/1170 + tag = TAG_RULES, + ) +] +#[axum::debug_handler] +#[tracing::instrument(skip(state))] +pub async fn update_rule_config( + version: Version, + State(state): State, + axum::Json(body): axum::Json, +) -> Result, AppError> { + let config = state + .update_rule_configuration( + UpdateRuleRequest { + configuration: Some(body), + } + .into_request(), + ) + .await? + .into_inner(); + + Ok(axum::Json(config)) +} -- cgit v1.2.3