refactor: done

This commit is contained in:
GyDi
2022-11-18 18:18:41 +08:00
parent ce2d4498e1
commit bedd3abf8a
24 changed files with 343 additions and 341 deletions

View File

@@ -1,19 +1,17 @@
use crate::{config::Config, utils::dirs};
use crate::config::Config;
use anyhow::{bail, Result};
use reqwest::header::HeaderMap;
use serde_yaml::Mapping;
use std::collections::HashMap;
/// PUT /configs
pub async fn put_configs() -> Result<()> {
/// path 是绝对路径
pub async fn put_configs(path: &str) -> Result<()> {
let (url, headers) = clash_client_info()?;
let url = format!("{url}/configs");
let runtime_yaml = dirs::clash_runtime_yaml()?;
let runtime_yaml = dirs::path_to_str(&runtime_yaml)?;
let mut data = HashMap::new();
data.insert("path", runtime_yaml);
data.insert("path", path);
let client = reqwest::ClientBuilder::new().no_proxy().build()?;
let builder = client.put(&url).headers(headers).json(&data);