Skip to content

Commit

Permalink
Simplify binary engine runner
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelff committed Dec 15, 2022
1 parent 115f2cf commit 91ab6d5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ mod binary;
mod direct;
mod node_api;

use std::collections::HashMap;

pub use binary::*;
pub use direct::*;
use hyper::HeaderMap;
Expand Down Expand Up @@ -163,16 +165,27 @@ impl Runner {
}
}

pub fn set_headers(&mut self, headers: Option<HeaderMap>) {
pub fn set_headers(&mut self, headers: HashMap<String, String>) {
match &mut self.inner {
RunnerType::Direct(_) => todo!(),
RunnerType::NodeApi(_) => todo!(),
RunnerType::Binary(r) => r.set_additional_headers(headers),
RunnerType::Binary(r) => {
let map = Some(HeaderMap::from_iter(
headers
.into_iter()
.map(|(k, v)| (k.parse().unwrap(), v.parse().unwrap())),
));
r.set_additional_headers(map)
}
}
}

pub fn clear_headers(&mut self) {
self.set_headers(None)
match &mut self.inner {
RunnerType::Direct(_) => todo!(),
RunnerType::NodeApi(_) => todo!(),
RunnerType::Binary(r) => r.set_additional_headers(None),
}
}

async fn direct(datamodel: String, connector_tag: ConnectorTag, metrics: MetricRegistry) -> TestResult<RunnerType> {
Expand Down
1 change: 1 addition & 0 deletions query-engine/query-engine/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ async fn graphql_handler(state: State, req: Request<Body>) -> Result<Response<Bo
"result": result,
"traces": traces,
});
dbg!(&json);
serde_json::to_vec(&json).unwrap()
} else {
serde_json::to_vec(&result).unwrap()
Expand Down

0 comments on commit 91ab6d5

Please sign in to comment.