style(lib): run rustfmt and enforce in CI

This commit is contained in:
Sean McArthur
2019-12-05 13:30:53 -08:00
parent b0060f277e
commit 0dc89680cd
69 changed files with 2982 additions and 2499 deletions

View File

@@ -1,7 +1,7 @@
#![deny(warnings)]
use hyper::{Client, Error, Server};
use hyper::service::{make_service_fn, service_fn};
use hyper::{Client, Error, Server};
use std::net::SocketAddr;
#[tokio::main]
@@ -19,15 +19,17 @@ async fn main() {
// creating a 'service' to handle requests for that specific connection.
let make_service = make_service_fn(move |_| {
let client = client_main.clone();
async move {
// This is the `Service` that will handle the connection.
// `service_fn` is a helper to convert a function that
// returns a Response into a `Service`.
Ok::<_, Error>(service_fn(move |mut req| {
let uri_string = format!("http://{}/{}",
out_addr_clone,
req.uri().path_and_query().map(|x| x.as_str()).unwrap_or(""));
let uri_string = format!(
"http://{}/{}",
out_addr_clone,
req.uri().path_and_query().map(|x| x.as_str()).unwrap_or("")
);
let uri = uri_string.parse().unwrap();
*req.uri_mut() = uri;
client.request(req)
@@ -35,8 +37,7 @@ async fn main() {
}
});
let server = Server::bind(&in_addr)
.serve(make_service);
let server = Server::bind(&in_addr).serve(make_service);
println!("Listening on http://{}", in_addr);
println!("Proxying on http://{}", out_addr);