1- use super :: function_traits:: BorrowFromStr ;
21use super :: { ExecutionContext , RequestInfo } ;
32use crate :: webserver:: {
43 database:: {
5- blob_to_data_url:: vec_to_data_uri_with_mime, execute_queries:: DbConn ,
6- sqlpage_functions:: url_parameters:: URLParameters ,
4+ blob_to_data_url:: vec_to_data_uri_with_mime,
5+ execute_queries:: DbConn ,
6+ sqlpage_functions:: { http_fetch_request:: HttpFetchRequest , url_parameters:: URLParameters } ,
77 } ,
88 http_client:: make_http_client,
99 request_variables:: SetVariablesMap ,
@@ -27,8 +27,8 @@ super::function_definition_macro::sqlpage_functions! {
2727 environment_variable( name: Cow <str >) ;
2828 exec( ( & RequestInfo ) , program_name: Cow <str >, args: Vec <Cow <str >>) ;
2929
30- fetch( ( & RequestInfo ) , http_request: Option <Cow < str >>) ;
31- fetch_with_meta( ( & RequestInfo ) , http_request: Option <Cow < str >>) ;
30+ fetch( ( & RequestInfo ) , http_request: Option <SqlPageFunctionParam < HttpFetchRequest < ' _> >>) ;
31+ fetch_with_meta( ( & RequestInfo ) , http_request: Option <SqlPageFunctionParam < HttpFetchRequest < ' _> >>) ;
3232
3333 hash_password( password: Option <String >) ;
3434 header( ( & RequestInfo ) , name: Cow <str >) ;
@@ -186,14 +186,11 @@ fn prepare_request_body(
186186
187187async fn fetch (
188188 request : & RequestInfo ,
189- http_request : Option < Cow < ' _ , str > > ,
189+ http_request : Option < HttpFetchRequest < ' _ > > ,
190190) -> anyhow:: Result < Option < String > > {
191- let Some ( http_request_str ) = http_request else {
191+ let Some ( http_request ) = http_request else {
192192 return Ok ( None ) ;
193193 } ;
194- let http_request =
195- super :: http_fetch_request:: HttpFetchRequest :: borrow_from_str ( http_request_str)
196- . with_context ( || "Invalid http fetch request" ) ?;
197194 let client = make_http_client ( & request. app_state . config )
198195 . with_context ( || "Unable to create an HTTP client" ) ?;
199196 let req = build_request ( & client, & http_request) ?;
@@ -266,15 +263,13 @@ fn decode_response(response: Vec<u8>, encoding: Option<&str>) -> anyhow::Result<
266263
267264async fn fetch_with_meta (
268265 request : & RequestInfo ,
269- http_request : Option < Cow < ' _ , str > > ,
266+ http_request : Option < HttpFetchRequest < ' _ > > ,
270267) -> anyhow:: Result < Option < String > > {
271268 use serde:: { ser:: SerializeMap , Serializer } ;
272- let Some ( http_request_str) = http_request else {
269+
270+ let Some ( http_request) = http_request else {
273271 return Ok ( None ) ;
274272 } ;
275- let http_request =
276- super :: http_fetch_request:: HttpFetchRequest :: borrow_from_str ( http_request_str)
277- . with_context ( || "Invalid http fetch request" ) ?;
278273
279274 let client = make_http_client ( & request. app_state . config )
280275 . with_context ( || "Unable to create an HTTP client" ) ?;
0 commit comments