Struct salvo::hyper::Client [−][src]
pub struct Client<C, B = Body> { /* fields omitted */ }
Expand description
A Client to make outgoing HTTP requests.
Implementations
Create a new Client with the default config.
Note
The default connector does not handle TLS. Speaking to https
destinations will require configuring a connector that implements
TLS.
pub fn get(&self, uri: Uri) -> ResponseFutureⓘNotable traits for ResponseFutureimpl Future for ResponseFuture type Output = Result<Response<Body>, Error>;
where
B: Default,
pub fn get(&self, uri: Uri) -> ResponseFutureⓘNotable traits for ResponseFutureimpl Future for ResponseFuture type Output = Result<Response<Body>, Error>;
where
B: Default,
impl Future for ResponseFuture type Output = Result<Response<Body>, Error>;
Send a GET
request to the supplied Uri
.
Note
This requires that the HttpBody
type have a Default
implementation.
It should return an “empty” version of itself, such that
HttpBody::is_end_stream
is true
.
Example
use hyper::{Client, Uri};
let client = Client::new();
let future = client.get(Uri::from_static("http://httpbin.org/ip"));
pub fn request(&self, req: Request<B>) -> ResponseFutureⓘNotable traits for ResponseFutureimpl Future for ResponseFuture type Output = Result<Response<Body>, Error>;
pub fn request(&self, req: Request<B>) -> ResponseFutureⓘNotable traits for ResponseFutureimpl Future for ResponseFuture type Output = Result<Response<Body>, Error>;
impl Future for ResponseFuture type Output = Result<Response<Body>, Error>;
Send a constructed Request
using this Client
.
Example
use hyper::{Body, Client, Request};
let client = Client::new();
let req = Request::builder()
.method("POST")
.uri("http://httpbin.org/post")
.body(Body::from("Hallo!"))
.expect("request builder");
let future = client.request(req);
Trait Implementations
Returns the “default value” for a type. Read more
type Future = ResponseFuture
type Future = ResponseFuture
The future response value.
Returns Poll::Ready(Ok(()))
when the service is able to process requests. Read more
type Future = ResponseFuture
type Future = ResponseFuture
The future response value.
Returns Poll::Ready(Ok(()))
when the service is able to process requests. Read more
Auto Trait Implementations
impl<C, B = Body> !RefUnwindSafe for Client<C, B>
impl<C, B = Body> !UnwindSafe for Client<C, B>
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self