@@ -9,7 +9,9 @@ use std::io::Write;
9
9
10
10
#[ derive( Deserialize ) ]
11
11
struct RequestOptions {
12
+ #[ serde( default ) ]
12
13
output_filename : Option < String > ,
14
+ #[ serde( default ) ]
13
15
body_filename : Option < String > ,
14
16
}
15
17
@@ -22,8 +24,8 @@ struct Response<'a> {
22
24
23
25
// If the response can be deserialized -> success.
24
26
// If the response can't be deserialized -> failure.
25
- byond_fn ! ( fn http_request_blocking( method, url, body, headers, ...rest ) {
26
- let req = match construct_request( method, url, body, headers, rest . first ( ) . map ( |x| & * * x ) ) {
27
+ byond_fn ! ( fn http_request_blocking( method, url, body, headers, options ) {
28
+ let req = match construct_request( method, url, body, headers, options ) {
27
29
Ok ( r) => r,
28
30
Err ( e) => return Some ( e. to_string( ) )
29
31
} ;
@@ -35,8 +37,8 @@ byond_fn!(fn http_request_blocking(method, url, body, headers, ...rest) {
35
37
} ) ;
36
38
37
39
// Returns new job-id.
38
- byond_fn ! ( fn http_request_async( method, url, body, headers, ...rest ) {
39
- let req = match construct_request( method, url, body, headers, rest . first ( ) . map ( |x| & * * x ) ) {
40
+ byond_fn ! ( fn http_request_async( method, url, body, headers, options ) {
41
+ let req = match construct_request( method, url, body, headers, options ) {
40
42
Ok ( r) => r,
41
43
Err ( e) => return Some ( e. to_string( ) )
42
44
} ;
@@ -91,7 +93,7 @@ fn construct_request(
91
93
url : & str ,
92
94
body : & str ,
93
95
headers : & str ,
94
- options : Option < & str > ,
96
+ options : & str ,
95
97
) -> Result < RequestPrep > {
96
98
let mut req = match method {
97
99
"post" => HTTP_CLIENT . post ( url) ,
@@ -114,7 +116,7 @@ fn construct_request(
114
116
}
115
117
116
118
let mut output_filename = None ;
117
- if let Some ( options) = options {
119
+ if ! options. is_empty ( ) {
118
120
let options: RequestOptions = serde_json:: from_str ( options) ?;
119
121
output_filename = options. output_filename ;
120
122
if let Some ( fname) = options. body_filename {
0 commit comments