use serde::{Serialize, Deserialize}; use std::collections::HashMap; use anyhow::Result; #[derive(Serialize, Deserialize, Debug)] pub struct ServiceEntry { Tags: Vec } #[derive(Serialize, Deserialize, Debug)] pub struct CatalogNode { Services: HashMap } pub struct Consul { client: reqwest::Client, url: String } impl Consul { pub fn new(url: &str) -> Self { return Self { client: reqwest::Client::new(), url: url.to_string() }; } pub async fn catalog_node(&self, host: &str) -> Result { let url = format!("{}/v1/catalog/node/{}", self.url, host); let resp: CatalogNode = self.client.get(&url).send().await?.json().await?; return Ok(resp) } }