config api replace + struct of config changed

pull/3/head
prplV 2025-01-16 14:37:03 +03:00
parent 60d325e4bf
commit 186674da22
3 changed files with 22 additions and 10 deletions

13
config_api.json Normal file
View File

@ -0,0 +1,13 @@
{
"endpoints" : [
{
"url" : "http://127.0.0.1:8081/ping",
"method" : "GET"
},
{
"url" : "http://127.0.0.1:8081/",
"method" : "GET"
}
],
"delay" : 5
}

View File

@ -1,5 +0,0 @@
{
"api-endpoint" : "http://127.0.0.1:8081/ping",
"method" : "GET",
"delay" : "5"
}

View File

@ -1,19 +1,23 @@
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize, Debug)]
pub struct ApiConfig { pub struct ApiConfig {
url : String, #[serde(default)]
method : String, endpoints : Vec<ApiEndpoint>,
delay : u32, delay : u32,
} }
#[derive(Serialize, Deserialize, Debug)]
pub struct ApiEndpoint {
url : String,
method : String,
}
impl Default for ApiConfig { impl Default for ApiConfig {
fn default() -> Self { fn default() -> Self {
ApiConfig { ApiConfig {
url : String::new(), endpoints : vec![],
method : String::new(),
delay : 0, delay : 0,
} }
} }