Skip to content

Commit

Permalink
Remove obsolete telemetry_delete macro and update integration delete …
Browse files Browse the repository at this point in the history
…handling in v1 routers

- Remove the `telemetry_delete` macro from `utils.rs`, as it is no longer needed.
- Update `handle_v1_integration_delete` function to use query parameters instead of parsing JSON from the request body.
- Modify the `/integration-delete` route in `v1.rs` to directly use the `delete` handler without the telemetry macro.
  • Loading branch information
JegernOUTT committed Dec 16, 2024
1 parent 0b1f102 commit 5e652d1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/http/routers/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use hyper::Body;
use hyper::Response;
use tower_http::cors::CorsLayer;

use crate::{telemetry_delete, telemetry_get, telemetry_post};
use crate::{telemetry_get, telemetry_post};
use crate::custom_error::ScratchError;
use crate::global_context::SharedGlobalContext;
use crate::http::routers::v1::code_completion::{handle_v1_code_completion_web, handle_v1_code_completion_prompt};
Expand Down Expand Up @@ -129,7 +129,7 @@ pub fn make_v1_router() -> Router {
.route("/integrations-filtered/:integr_name", get(handle_v1_integrations_filtered))
.route("/integration-get", telemetry_post!(handle_v1_integration_get))
.route("/integration-save", telemetry_post!(handle_v1_integration_save))
.route("/integration-delete", telemetry_delete!(handle_v1_integration_delete))
.route("/integration-delete", delete(handle_v1_integration_delete))
.route("/integration-icon/:icon_name", get(handle_v1_integration_icon))

.route("/docker-container-list", telemetry_post!(handle_v1_docker_container_list))
Expand Down
8 changes: 3 additions & 5 deletions src/http/routers/v1/v1_integrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use serde::Deserialize;
use tokio::sync::RwLock as ARwLock;
use regex::Regex;
use axum::extract::Path;
use axum::extract::Query;


use crate::custom_error::ScratchError;
Expand Down Expand Up @@ -159,12 +160,9 @@ pub struct HTTPIntegrationDeleteQueryParams {
}

pub async fn handle_v1_integration_delete(
Extension(_gcx): Extension<Arc<ARwLock<GlobalContext>>>,
body_bytes: hyper::body::Bytes,
Query(params): Query<HTTPIntegrationDeleteQueryParams>,
) -> axum::response::Result<Response<Body>, ScratchError> {
let data = serde_json::from_slice::<HTTPIntegrationDeleteQueryParams>(&body_bytes)
.map_err(|e| ScratchError::new(StatusCode::UNPROCESSABLE_ENTITY, format!("JSON problem: {}", e)))?;
let integration_path = data.integration_path;
let integration_path = params.integration_path;
log::info!("Deleting integration path: {:?}", integration_path);

split_path_into_project_and_integration(&integration_path).map_err(
Expand Down
16 changes: 0 additions & 16 deletions src/http/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,3 @@ macro_rules! telemetry_get {
})
};
}

#[macro_export]
macro_rules! telemetry_delete {
(
$name:ident
) => {
delete(|path, method, ex, body_bytes| async {
let tmp = |ex: Extension<SharedGlobalContext>, body_bytes: hyper::body::Bytes|
-> Pin<Box<dyn Future<Output=Result<Response<Body>, ScratchError>> + Send>> {
Box::pin($name(ex, body_bytes))
};
telemetry_wrapper(tmp, path, method, ex, body_bytes).await
})
};
}

0 comments on commit 5e652d1

Please sign in to comment.