From 186674da2280b851e9abeaa8244891bdb585c220 Mon Sep 17 00:00:00 2001 From: prplV Date: Thu, 16 Jan 2025 14:37:03 +0300 Subject: [PATCH] config api replace + struct of config changed --- config_api.json | 13 +++++++++++++ crates/api-grub/config.json | 5 ----- crates/integr-structs/src/api.rs | 14 +++++++++----- 3 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 config_api.json delete mode 100644 crates/api-grub/config.json diff --git a/config_api.json b/config_api.json new file mode 100644 index 0000000..9136b29 --- /dev/null +++ b/config_api.json @@ -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 +} \ No newline at end of file diff --git a/crates/api-grub/config.json b/crates/api-grub/config.json deleted file mode 100644 index f73fd93..0000000 --- a/crates/api-grub/config.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "api-endpoint" : "http://127.0.0.1:8081/ping", - "method" : "GET", - "delay" : "5" -} \ No newline at end of file diff --git a/crates/integr-structs/src/api.rs b/crates/integr-structs/src/api.rs index e8c66d3..ec472ba 100644 --- a/crates/integr-structs/src/api.rs +++ b/crates/integr-structs/src/api.rs @@ -1,19 +1,23 @@ use serde::{Serialize, Deserialize}; -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug)] pub struct ApiConfig { - url : String, - method : String, + #[serde(default)] + endpoints : Vec, delay : u32, } +#[derive(Serialize, Deserialize, Debug)] +pub struct ApiEndpoint { + url : String, + method : String, +} impl Default for ApiConfig { fn default() -> Self { ApiConfig { - url : String::new(), - method : String::new(), + endpoints : vec![], delay : 0, } }