Having the full reqwest response returned

This commit is contained in:
Dave Hrycyszyn
2019-12-10 16:59:55 +00:00
parent e3c94b6592
commit cd700a8760
2 changed files with 8 additions and 12 deletions
@@ -6,7 +6,7 @@ pub struct Requester {
pub trait HealthCheckRequester {
fn new(base_url: String) -> Self;
fn get(&self) -> Result<Response, reqwest::Error>;
fn make_request(&self) -> Result<Response, reqwest::Error>;
}
impl HealthCheckRequester for Requester {
@@ -16,7 +16,7 @@ impl HealthCheckRequester for Requester {
}
}
fn get(&self) -> Result<Response, reqwest::Error> {
fn make_request(&self) -> Result<Response, reqwest::Error> {
let url = format!("{}/healthcheck", self.base_url);
reqwest::get(&url)
}
@@ -39,7 +39,7 @@ mod healthcheck_requests {
.with_status(400)
.create();
let req = Requester::new(mockito::server_url());
assert_eq!(true, req.get().is_err());
assert_eq!(true, req.make_request().is_err());
}
}
@@ -54,7 +54,7 @@ mod healthcheck_requests {
.create();
let req = Requester::new(mockito::server_url());
assert_eq!(true, req.get().is_ok());
assert_eq!(true, req.make_request().is_ok());
}
}
}
+4 -8
View File
@@ -1,6 +1,6 @@
use sphinx::route::{Node as SphinxNode, Destination};
use crate::clients::directory::presence::models::Topology;
use reqwest::Error;
use reqwest::{Error};
use crate::clients::directory::healthcheck::requests::{Requester, HealthCheckRequester};
//use serde::Deserialize;
@@ -15,7 +15,7 @@ pub struct Config {
pub trait DirectoryClient {
fn new(config : Config) -> Self;
fn health_check(&self) -> Result<bool, Error>;
fn health_check(&self) -> Result<reqwest::Response, reqwest::Error>;
fn get_topology(&self) -> Result<Topology, reqwest::Error>;
// fn send_provider_presence(&self) -> Result<ProviderPresenceResponse, reqwest::Error>;
}
@@ -33,12 +33,8 @@ impl DirectoryClient for Client {
}
}
fn health_check(&self) -> Result<bool, Error> {
unimplemented!()
// match self.health_check.get() {
// true => Ok(true),
// false => Err("foo"),
// }
fn health_check(&self) -> Result<reqwest::Response, reqwest::Error> {
self.health_check.make_request()
}
fn get_topology(&self) -> Result<Topology, Error> {