fixed json in api call

This commit is contained in:
2025-10-29 21:35:54 +01:00
parent 375b4450f0
commit c36b17fa05

View File

@@ -15,13 +15,12 @@ use std::time::Duration;
use crate::docker::serverclientcomm::handle_server_message; use crate::docker::serverclientcomm::handle_server_message;
use crate::hardware::HardwareInfo; use crate::hardware::HardwareInfo;
use crate::models::{ use crate::models::{
Acknowledgment, DockerContainer, DockerMetricDto, DockerRegistrationDto, HeartbeatDto, Acknowledgment, DockerMetricDto, DockerRegistrationDto, HeartbeatDto,
IdResponse, MetricDto, RegistrationDto, ServerMessage, IdResponse, MetricDto, RegistrationDto, ServerMessage,
}; };
use anyhow::Result; use anyhow::Result;
use reqwest::{Client, StatusCode}; use reqwest::{Client, StatusCode};
use serde::Serialize;
use std::error::Error; use std::error::Error;
use tokio::time::sleep; use tokio::time::sleep;
@@ -210,7 +209,7 @@ pub async fn broadcast_docker_containers(
let json_body = serde_json::to_string_pretty(&broadcast_data)?; let json_body = serde_json::to_string_pretty(&broadcast_data)?;
println!("📤 JSON being posted:\n{}", json_body); println!("📤 JSON being posted:\n{}", json_body);
let url = format!("{}/monitoring/service-discovery", base_url); let url = format!("{}/monitoring/service-discovery", base_url);
match client.post(&url).json(&container_dto).send().await { match client.post(&url).json(&container_dto).send().await {
Ok(resp) if resp.status().is_success() => { Ok(resp) if resp.status().is_success() => {
@@ -431,7 +430,8 @@ pub async fn send_docker_metrics(
) -> Result<(), Box<dyn Error + Send + Sync>> { ) -> Result<(), Box<dyn Error + Send + Sync>> {
let client = Client::new(); let client = Client::new();
let url = format!("{}/monitoring/docker-metric", base_url); let url = format!("{}/monitoring/docker-metric", base_url);
println!("Docker Metrics: {:?}", docker_metrics);
println!("Docker Metrics: {}", serde_json::to_string_pretty(&docker_metrics)?);
match client.post(&url).json(&docker_metrics).send().await { match client.post(&url).json(&docker_metrics).send().await {
Ok(res) => println!( Ok(res) => println!(