@@ -20,10 +20,11 @@ use tucana::shared::{Struct, Value};
2020use ureq:: http;
2121use ureq:: { Body , RequestExt } ;
2222
23- pub ( crate ) const FUNCTIONS : & [ FunctionRegistration ] = & [
24- FunctionRegistration :: eager ( "http::request::send" , send_request, 8 ) ,
25- FunctionRegistration :: eager ( "rest::control::respond" , respond, 4 ) ,
26- ] ;
23+ pub ( crate ) const FUNCTIONS : & [ FunctionRegistration ] = & [ FunctionRegistration :: eager (
24+ "http::request::send" ,
25+ send_request,
26+ 8 ,
27+ ) ] ;
2728
2829fn fail ( category : & str , message : impl Into < String > ) -> Signal {
2930 Signal :: Failure ( RuntimeError :: new ( "T-STD-00001" , category, message) )
@@ -42,36 +43,6 @@ fn run_blocking<R>(f: impl FnOnce() -> R) -> R {
4243 }
4344}
4445
45- fn respond (
46- args : & [ Argument ] ,
47- _ctx : & mut ValueStore ,
48- _run : & mut crate :: handler:: registry:: ThunkRunner < ' _ > ,
49- ) -> Signal {
50- args ! ( args => http_status_code: i64 , http_schema: String , payload: Value , headers: Value ) ;
51-
52- let http_headers = match headers_from_value ( & headers) {
53- Ok ( headers) => headers,
54- Err ( signal) => return signal,
55- } ;
56-
57- let mut fields = HashMap :: new ( ) ;
58- fields. insert ( "http_status_code" . to_string ( ) , http_status_code. to_value ( ) ) ;
59- fields. insert (
60- "headers" . to_string ( ) ,
61- Value {
62- kind : Some ( Kind :: StructValue ( http_headers) ) ,
63- } ,
64- ) ;
65-
66- fields. insert ( "payload" . to_string ( ) , payload) ;
67- fields. insert ( "http_schema" . to_string ( ) , http_schema. to_value ( ) ) ;
68-
69- // `Respond` is a control signal; the executor can still continue with `next` if present.
70- Signal :: Respond ( Value {
71- kind : Some ( Kind :: StructValue ( Struct { fields } ) ) ,
72- } )
73- }
74-
7546#[ derive( Clone , Debug , Eq , PartialEq ) ]
7647enum HttpAuthType {
7748 None ,
0 commit comments