chore: add https_check
This commit is contained in:
parent
ea591729d7
commit
37174546c3
27
src/utils.rs
27
src/utils.rs
@ -7,10 +7,37 @@ use std::io::{Write};
|
||||
use std::net::TcpStream;
|
||||
use std::path::Path;
|
||||
use std::process::{Command};
|
||||
use hyper_tls::HttpsConnector;
|
||||
use hyper::Client;
|
||||
use hyper::http::StatusCode;
|
||||
use std::error::Error;
|
||||
|
||||
use crate::defs::{SSHAccess,Cntrllr};
|
||||
use crate::clouds::defs::{Cloud};
|
||||
|
||||
pub async fn https_check(url: &str) -> Result<(), Box<dyn Error>> {
|
||||
let https = HttpsConnector::new();
|
||||
let client = Client::builder().build::<_, hyper::Body>(https);
|
||||
let req = client.get(url.parse()?).await;
|
||||
match req {
|
||||
Ok(res) =>
|
||||
match res.status() {
|
||||
StatusCode::OK => {
|
||||
println!("OK");
|
||||
Ok(())
|
||||
},
|
||||
_ => {
|
||||
dbg!(res.status());
|
||||
println!("Err");
|
||||
Err("Error".into())
|
||||
},
|
||||
},
|
||||
Err(e) => {
|
||||
Err(format!("Error {}: {}",&url,e).into())
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_yaml_value(value: serde_yaml::Value, key: String, ctx: &mut tera::Context ) {
|
||||
if let Some(v) = value.as_str() {
|
||||
ctx.insert(key.to_owned(),&v);
|
||||
|
Loading…
Reference in New Issue
Block a user