The only important trait for a user is the `tower::Service` trait, which is now available also at `hyper::service::Service`. The other "trait aliases" are no longer publicly exported, as people thought they had to implement them. Also removes dependency on `tower-make`, which is trivial but otherwise shouldn't affect anyone. Closes #1959
29 lines
651 B
Rust
29 lines
651 B
Rust
#![deny(warnings)]
|
|
|
|
use hyper::client::service::Connect;
|
|
use hyper::client::conn::Builder;
|
|
use hyper::client::connect::HttpConnector;
|
|
use hyper::service::Service;
|
|
use hyper::{Body, Request};
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
pretty_env_logger::init();
|
|
|
|
let mut mk_svc = Connect::new(HttpConnector::new(), Builder::new());
|
|
|
|
let uri = "http://127.0.0.1:8080".parse::<http::Uri>()?;
|
|
|
|
|
|
let mut svc = mk_svc.call(uri.clone()).await?;
|
|
|
|
let body = Body::empty();
|
|
|
|
let req = Request::get(uri).body(body)?;
|
|
let res = svc.call(req).await?;
|
|
|
|
println!("RESPONSE={:?}", res);
|
|
|
|
Ok(())
|
|
}
|