From e0c8e11ae386547666ec6c9359d72b86034be356 Mon Sep 17 00:00:00 2001 From: laststylebender Date: Mon, 9 Dec 2024 12:22:06 +0530 Subject: [PATCH] - conflict changes --- src/core/generator/proto/connect_rpc.rs | 9 +++++---- src/core/ir/eval_http.rs | 11 ++++++----- ...i__fixtures__generator__proto-connect-rpc.md.snap | 12 ++++++------ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/core/generator/proto/connect_rpc.rs b/src/core/generator/proto/connect_rpc.rs index 4363631e2c..14fb51243b 100644 --- a/src/core/generator/proto/connect_rpc.rs +++ b/src/core/generator/proto/connect_rpc.rs @@ -55,7 +55,7 @@ impl From for Http { Self { url: new_url, - body: body.map(|b| b.to_string()), + body, method: crate::core::http::Method::POST, headers, batch_key, @@ -91,7 +91,7 @@ mod tests { assert_eq!(http.url, "http://localhost:8080/package.service/method"); assert_eq!(http.method, crate::core::http::Method::POST); - assert_eq!(http.body, Some(r#"{"key":"value"}"#.to_string())); + assert_eq!(http.body, Some(json!({"key": "value"}))); } #[test] @@ -109,7 +109,7 @@ mod tests { let http = Http::from(grpc); - assert_eq!(http.body, Some("{}".to_string())); + assert_eq!(http.body, Some(json!({}))); } #[test] @@ -136,6 +136,7 @@ mod tests { .value, "bar".to_string() ); + assert_eq!(http.body, Some(json!({}))); } #[test] @@ -155,7 +156,7 @@ mod tests { assert_eq!(http.url, "http://localhost:8080/package.service/method"); assert_eq!(http.method, crate::core::http::Method::POST); - assert_eq!(http.body, Some(r#"{"key":"value"}"#.to_string())); + assert_eq!(http.body, Some(json!({"key": "value"}))); assert_eq!( http.headers .iter() diff --git a/src/core/ir/eval_http.rs b/src/core/ir/eval_http.rs index c1107e1a41..ccaa334ac3 100644 --- a/src/core/ir/eval_http.rs +++ b/src/core/ir/eval_http.rs @@ -104,13 +104,14 @@ impl<'a, 'ctx, Context: ResolverContextLike + Sync> EvalHttp<'a, 'ctx, Context> pub async fn execute_with_worker<'worker: 'async_recursion>( &self, mut request: DynamicRequest, - worker: &Arc>, - http_filter: &HttpFilter, + worker_ctx: WorkerContext<'worker>, ) -> Result, Error> { - let js_request = worker::WorkerRequest::try_from(request.request())?; - let event = worker::Event::Request(js_request); + // extract variables from the worker context. + let js_hooks = worker_ctx.js_hooks; + let worker = worker_ctx.worker; + let js_worker = worker_ctx.js_worker; - let response = match js_hooks.on_request(worker, &request).await? { + let response = match js_hooks.on_request(worker, &request.request()).await? { Some(command) => match command { worker::Command::Request(w_request) => { let response = self.execute(w_request.try_into()?).await?; diff --git a/tests/cli/snapshots/cli_spec__test__generator_spec__tests__cli__fixtures__generator__proto-connect-rpc.md.snap b/tests/cli/snapshots/cli_spec__test__generator_spec__tests__cli__fixtures__generator__proto-connect-rpc.md.snap index 23a4aba11f..b4581cc432 100644 --- a/tests/cli/snapshots/cli_spec__test__generator_spec__tests__cli__fixtures__generator__proto-connect-rpc.md.snap +++ b/tests/cli/snapshots/cli_spec__test__generator_spec__tests__cli__fixtures__generator__proto-connect-rpc.md.snap @@ -60,12 +60,12 @@ type News { } type Query { - GEN__news__NewsService__AddNews(news: GEN__news__NewsInput!): News @http(url: "http://localhost:50051/news.NewsService/AddNews", body: "\"{{.args.news}}\"", method: "POST") - GEN__news__NewsService__DeleteNews(newsId: Id!): Empty @http(url: "http://localhost:50051/news.NewsService/DeleteNews", body: "\"{{.args.newsId}}\"", method: "POST") - GEN__news__NewsService__EditNews(news: GEN__news__NewsInput!): News @http(url: "http://localhost:50051/news.NewsService/EditNews", body: "\"{{.args.news}}\"", method: "POST") - GEN__news__NewsService__GetAllNews: GEN__news__NewsList @http(url: "http://localhost:50051/news.NewsService/GetAllNews", body: "{}", method: "POST") - GEN__news__NewsService__GetMultipleNews(multipleNewsId: GEN__news__MultipleNewsId!): GEN__news__NewsList @http(url: "http://localhost:50051/news.NewsService/GetMultipleNews", body: "\"{{.args.multipleNewsId}}\"", method: "POST") - GEN__news__NewsService__GetNews(newsId: Id!): News @http(url: "http://localhost:50051/news.NewsService/GetNews", body: "\"{{.args.newsId}}\"", method: "POST") + GEN__news__NewsService__AddNews(news: GEN__news__NewsInput!): News @http(url: "http://localhost:50051/news.NewsService/AddNews", body: "{{.args.news}}", method: "POST") + GEN__news__NewsService__DeleteNews(newsId: Id!): Empty @http(url: "http://localhost:50051/news.NewsService/DeleteNews", body: "{{.args.newsId}}", method: "POST") + GEN__news__NewsService__EditNews(news: GEN__news__NewsInput!): News @http(url: "http://localhost:50051/news.NewsService/EditNews", body: "{{.args.news}}", method: "POST") + GEN__news__NewsService__GetAllNews: GEN__news__NewsList @http(url: "http://localhost:50051/news.NewsService/GetAllNews", body: {}, method: "POST") + GEN__news__NewsService__GetMultipleNews(multipleNewsId: GEN__news__MultipleNewsId!): GEN__news__NewsList @http(url: "http://localhost:50051/news.NewsService/GetMultipleNews", body: "{{.args.multipleNewsId}}", method: "POST") + GEN__news__NewsService__GetNews(newsId: Id!): News @http(url: "http://localhost:50051/news.NewsService/GetNews", body: "{{.args.newsId}}", method: "POST") users: [User] @http(url: "http://jsonplaceholder.typicode.com/users") }