mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-12-14 03:36:59 +08:00
43a0a4f8e0
* add http(s) proxy
* Add front-end translation
* fix ui description
* For linux platform, add rustls support
* fix: Fix the proxy address test function.
* add: Added default prompts for agency agreement and some multi-language translations
* add: Http proxy request client
* fix: add async http proxy func and format the code
* add: Preliminary support for flutter front-end calling rust back-end http request
* Optimize HTTP calls
* Optimize HTTP calls
* fix: Optimize HTTP requests, refine translations, and fix dependencies
* fix: Win and macOS compilation errors
* fix: web platforms
* fix: Optimize import
* fix: Fix web platform issues
* fix: Fix web platform issues
* fix: update ci
* fix: test ci
* test: test CI
* Revert "fix: update ci"
This reverts commit 2e5f247b2e
.
* test: test CI
* test: test CI
* fix: fix lock file
* fix: Optimize imports
40 lines
1.0 KiB
Rust
40 lines
1.0 KiB
Rust
use reqwest::blocking::Response;
|
|
use serde::de::DeserializeOwned;
|
|
use serde_json::{Map, Value};
|
|
|
|
#[cfg(feature = "flutter")]
|
|
pub mod account;
|
|
mod http_client;
|
|
pub mod record_upload;
|
|
pub mod sync;
|
|
pub use http_client::create_http_client;
|
|
pub use http_client::create_http_client_async;
|
|
|
|
#[derive(Debug)]
|
|
pub enum HbbHttpResponse<T> {
|
|
ErrorFormat,
|
|
Error(String),
|
|
DataTypeFormat,
|
|
Data(T),
|
|
}
|
|
|
|
impl<T: DeserializeOwned> TryFrom<Response> for HbbHttpResponse<T> {
|
|
type Error = reqwest::Error;
|
|
|
|
fn try_from(resp: Response) -> Result<Self, <Self as TryFrom<Response>>::Error> {
|
|
let map = resp.json::<Map<String, Value>>()?;
|
|
if let Some(error) = map.get("error") {
|
|
if let Some(err) = error.as_str() {
|
|
Ok(Self::Error(err.to_owned()))
|
|
} else {
|
|
Ok(Self::ErrorFormat)
|
|
}
|
|
} else {
|
|
match serde_json::from_value(Value::Object(map)) {
|
|
Ok(v) => Ok(Self::Data(v)),
|
|
Err(_) => Ok(Self::DataTypeFormat),
|
|
}
|
|
}
|
|
}
|
|
}
|