Skip to content

Commit 8d0e88d

Browse files
committed
fix: synced names with definitions
1 parent c2e3a6e commit 8d0e88d

1 file changed

Lines changed: 13 additions & 21 deletions

File tree

  • crates/core/src/runtime/functions

crates/core/src/runtime/functions/http.rs

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::context::macros::args;
44
use crate::context::registry::{HandlerFn, HandlerFunctionEntry, IntoFunctionEntry};
55
use crate::context::signal::Signal;
66
use crate::runtime::error::RuntimeError;
7-
use crate::value::value_from_i64;
7+
use tucana::shared::helper::value::ToValue;
88
use tucana::shared::value::Kind;
99
use tucana::shared::{Struct, Value};
1010

@@ -34,7 +34,7 @@ fn respond(
3434
));
3535
};
3636

37-
let Some(status_code_val) = fields.get("status_code") else {
37+
let Some(status_code_val) = fields.get("http_status_code") else {
3838
return Signal::Failure(RuntimeError::simple(
3939
"InvalidArgumentRuntimeError",
4040
"Missing 'status_code' field".to_string(),
@@ -82,27 +82,15 @@ fn create_request(
8282
args!(args => http_method: String, headers: Struct, http_url: String, payload: Value);
8383
let mut fields = std::collections::HashMap::new();
8484

85+
fields.insert(String::from("http_method"), http_method.to_value());
86+
fields.insert(String::from("url"), http_url.to_value());
87+
fields.insert(String::from("payload"), payload.clone());
8588
fields.insert(
86-
"method".to_string(),
87-
Value {
88-
kind: Some(Kind::StringValue(http_method.clone())),
89-
},
90-
);
91-
92-
fields.insert(
93-
"url".to_string(),
94-
Value {
95-
kind: Some(Kind::StringValue(http_url.clone())),
96-
},
97-
);
98-
99-
fields.insert(
100-
"headers".to_string(),
89+
String::from("headers"),
10190
Value {
10291
kind: Some(Kind::StructValue(headers.clone())),
10392
},
10493
);
105-
fields.insert("body".to_string(), payload.clone());
10694

10795
Signal::Success(Value {
10896
kind: Some(Kind::StructValue(Struct { fields })),
@@ -116,15 +104,19 @@ fn create_response(
116104
) -> Signal {
117105
args!(args => http_status_code: i64, headers: Struct, payload: Value);
118106
let mut fields = std::collections::HashMap::new();
119-
fields.insert("status_code".to_string(), value_from_i64(http_status_code));
120107

121108
fields.insert(
122-
"headers".to_string(),
109+
String::from("http_status_code"),
110+
http_status_code.to_value(),
111+
);
112+
fields.insert(String::from("payload"), payload.clone());
113+
114+
fields.insert(
115+
String::from("headers"),
123116
Value {
124117
kind: Some(Kind::StructValue(headers.clone())),
125118
},
126119
);
127-
fields.insert("payload".to_string(), payload.clone());
128120

129121
Signal::Success(Value {
130122
kind: Some(Kind::StructValue(Struct { fields })),

0 commit comments

Comments
 (0)