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 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 req_data = NetworkReq {
|
||||
@ -210,21 +210,22 @@ pub async fn get_my_networks() -> Result<NetworkResp>{
|
||||
.timeout(Duration::from_secs(5)).build() else {
|
||||
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)
|
||||
.send().await {
|
||||
|
||||
Ok(response) => {
|
||||
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) => {
|
||||
println!("failed to send get_all_networks: {}", e);
|
||||
return Err(SDLanError::NormalError("failed to send get_all_networks"));
|
||||
error!("failed to send get_user_network: {}", e);
|
||||
return Err(SDLanError::NormalError("failed to get_user_network"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user