Explorar el Código

reqwest是甲级战犯。

skyfffire hace 2 años
padre
commit
7bfd1dbe58
Se han modificado 1 ficheros con 1 adiciones y 4 borrados
  1. 1 4
      global/src/log_utils.rs

+ 1 - 4
global/src/log_utils.rs

@@ -46,7 +46,6 @@ impl Visit for ErrorMessageVisitor {
 
 // 错误报告发送到指定服务器
 struct ReportingLayer {
-    client: Client,
     account_name: String,
 }
 impl<S> Layer<S> for ReportingLayer
@@ -61,14 +60,13 @@ impl<S> Layer<S> for ReportingLayer
             event.record(&mut visitor);
 
             let msg = format!("account={}, msg={}", self.account_name.clone(), visitor.message);
-            let client = self.client.clone();
             tokio::spawn(async move {
                 let encoded_str = base64::encode(msg.clone());
                 let mut request_json_data = HashMap::new();
                 request_json_data.insert("serverName", "As");
                 request_json_data.insert("data", encoded_str.as_str());
 
-                let res = client.post("https://hhh.liangjiang.cc/api/log/addError?key=d64a8sc874sa8c4as5")
+                let res = Client::new().post("https://hhh.liangjiang.cc/api/log/addError?key=d64a8sc874sa8c4as5")
                     .json(&request_json_data)
                     .send()
                     .await;
@@ -123,7 +121,6 @@ pub fn final_init(level: &str, port: u32, account_name: String) -> WorkerGuard {
         .with_span_events(fmt::format::FmtSpan::FULL);
 
     let reporting_layer = ReportingLayer {
-        client: Client::new(),
         account_name
     };