aboutsummaryrefslogtreecommitdiffstats
path: root/crates/configuration/src/server/http_svc/routes/routing/post_routing.rs
diff options
context:
space:
mode:
authorrtkay123 <dev@kanjala.com>2025-08-14 18:05:07 +0200
committerrtkay123 <dev@kanjala.com>2025-08-14 18:05:07 +0200
commit1b8c6886f6d22f9c61e978b42d066dce91e334dc (patch)
tree468fae725d2464baac9b27d6a02f67f24e3eeb9f /crates/configuration/src/server/http_svc/routes/routing/post_routing.rs
parent600c7a1942c06c0f7a0ae87448595057206bf324 (diff)
downloadwarden-1b8c6886f6d22f9c61e978b42d066dce91e334dc.tar.bz2
warden-1b8c6886f6d22f9c61e978b42d066dce91e334dc.zip
feat(config): rule grpc
Diffstat (limited to 'crates/configuration/src/server/http_svc/routes/routing/post_routing.rs')
-rw-r--r--crates/configuration/src/server/http_svc/routes/routing/post_routing.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/crates/configuration/src/server/http_svc/routes/routing/post_routing.rs b/crates/configuration/src/server/http_svc/routes/routing/post_routing.rs
new file mode 100644
index 0000000..3578b65
--- /dev/null
+++ b/crates/configuration/src/server/http_svc/routes/routing/post_routing.rs
@@ -0,0 +1,39 @@
+use axum::{extract::State, response::IntoResponse};
+use warden_core::configuration::routing::{
+ RoutingConfiguration, mutate_routing_server::MutateRouting,
+};
+
+use crate::{
+ server::{error::AppError, http_svc::TAG_ROUTING, version::Version},
+ state::AppHandle,
+};
+
+/// Create routing configuration
+#[utoipa::path(
+ post,
+ responses((
+ status = CREATED,
+ body = RoutingConfiguration
+ )),
+ operation_id = "post_routing_configuration", // https://github.com/juhaku/utoipa/issues/1170
+ path = "/{version}/routing",
+ params(
+ ("version" = Version, Path, description = "API version, e.g., v1, v2, v3")
+ ),
+ tag = TAG_ROUTING,
+)
+]
+#[axum::debug_handler]
+#[tracing::instrument(skip(state), err(Debug), fields(method = "POST"))]
+pub async fn post_routing(
+ version: Version,
+ State(state): State<AppHandle>,
+ axum::Json(body): axum::Json<RoutingConfiguration>,
+) -> Result<impl IntoResponse, AppError> {
+ let response = state
+ .create_routing_configuration(tonic::Request::new(body))
+ .await?
+ .into_inner();
+
+ Ok((axum::http::StatusCode::CREATED, axum::Json(response)))
+}