add: Preliminary support for flutter front-end calling rust back-end http request

This commit is contained in:
yuluo
2024-04-18 01:12:39 +08:00
parent 1176750a4f
commit 9588c3280f
6 changed files with 126 additions and 5 deletions

View File

@@ -708,6 +708,18 @@ pub fn change_id(id: String) {
});
}
#[inline]
pub fn http_request(url: String, method: String, body: String, header: String) {
*ASYNC_JOB_STATUS.lock().unwrap() = " ".to_owned();
std::thread::spawn(move || {
*ASYNC_JOB_STATUS.lock().unwrap() =
match crate::http_request_sync(url, method, body, header) {
Err(err) => err.to_string(),
Ok(text) => text,
};
});
}
#[inline]
pub fn post_request(url: String, body: String, header: String) {
*ASYNC_JOB_STATUS.lock().unwrap() = " ".to_owned();