aded get_my_networks api
This commit is contained in:
parent
1e429ad874
commit
6ab4f7042b
13
src/lib.rs
13
src/lib.rs
@ -199,7 +199,7 @@ pub struct NetworkResp {
|
|||||||
pub result: NetworkRespNetworks,
|
pub result: NetworkRespNetworks,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_my_networks() -> Result<NetworkResp>{
|
pub async fn get_my_networks(url: &str) -> Result<Vec<NetworkRespSingleNetwork>>{
|
||||||
let edge_uuid = create_or_load_uuid(&format!("{}/.id", get_base_dir()))?;
|
let edge_uuid = create_or_load_uuid(&format!("{}/.id", get_base_dir()))?;
|
||||||
|
|
||||||
let req_data = NetworkReq {
|
let req_data = NetworkReq {
|
||||||
@ -210,21 +210,22 @@ pub async fn get_my_networks() -> Result<NetworkResp>{
|
|||||||
.timeout(Duration::from_secs(5)).build() else {
|
.timeout(Duration::from_secs(5)).build() else {
|
||||||
return Err(SDLanError::NormalError("failed to create client"));
|
return Err(SDLanError::NormalError("failed to create client"));
|
||||||
};
|
};
|
||||||
match client.post("https://punchnet.s5s8.com/api/get_user_network")
|
// match client.post("https://punchnet.s5s8.com/api/get_user_network")
|
||||||
|
match client.post(url)
|
||||||
.json(&req_data)
|
.json(&req_data)
|
||||||
.send().await {
|
.send().await {
|
||||||
|
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let Ok(network) = response.json::<NetworkResp>().await else {
|
let Ok(network) = response.json::<NetworkResp>().await else {
|
||||||
return Err(SDLanError::NormalError("failed to jsonify get_all_networks "));
|
return Err(SDLanError::NormalError("failed to jsonify get_user_network "));
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(network)
|
Ok(network.result.network)
|
||||||
|
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("failed to send get_all_networks: {}", e);
|
error!("failed to send get_user_network: {}", e);
|
||||||
return Err(SDLanError::NormalError("failed to send get_all_networks"));
|
return Err(SDLanError::NormalError("failed to get_user_network"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user