aboutsummaryrefslogtreecommitdiff
path: root/src/consul.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/consul.rs')
-rw-r--r--src/consul.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/consul.rs b/src/consul.rs
index 4e4f79c..4677931 100644
--- a/src/consul.rs
+++ b/src/consul.rs
@@ -3,6 +3,8 @@ use std::collections::HashMap;
use anyhow::{anyhow, Result};
use serde::{Deserialize, Serialize};
+use crate::config::RuntimeConfigConsul;
+
#[derive(Serialize, Deserialize, Debug)]
pub struct ServiceEntry {
pub Tags: Vec<String>,
@@ -20,10 +22,20 @@ pub struct Consul {
}
impl Consul {
- pub fn new(url: &str) -> Self {
+ pub fn new(config: &RuntimeConfigConsul) -> Self {
+ let client = if let Some((ca, ident)) = config.tls.clone() {
+ reqwest::Client::builder()
+ .use_rustls_tls()
+ .add_root_certificate(ca)
+ .identity(ident)
+ .build()
+ .expect("Unable to build reqwest client")
+ } else {
+ reqwest::Client::new()
+ };
return Self {
- client: reqwest::Client::new(),
- url: url.to_string(),
+ client,
+ url: config.url.clone(),
idx: None,
};
}