Struct twistrs::constants::HTTP_CLIENT
source · pub struct HTTP_CLIENT { /* private fields */ }
Expand description
Global HTTP client we use throughout the library
Methods from Deref<Target = Client<HttpConnector>>§
sourcepub fn get(&self, uri: Uri) -> ResponseFuturewhere
B: Default,
pub fn get(&self, uri: Uri) -> ResponseFuturewhere B: Default,
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"));
sourcepub fn request(&self, req: Request<B>) -> ResponseFuture
pub fn request(&self, req: Request<B>) -> ResponseFuture
Send a constructed Request
using this Client
.
Example
use hyper::{Body, Method, Client, Request};
let client = Client::new();
let req = Request::builder()
.method(Method::POST)
.uri("http://httpbin.org/post")
.body(Body::from("Hallo!"))
.expect("request builder");
let future = client.request(req);
Trait Implementations§
source§impl Deref for HTTP_CLIENT
impl Deref for HTTP_CLIENT
§type Target = Client<HttpConnector>
type Target = Client<HttpConnector>
The resulting type after dereferencing.
source§fn deref(&self) -> &Client<HttpConnector>
fn deref(&self) -> &Client<HttpConnector>
Dereferences the value.
impl LazyStatic for HTTP_CLIENT
Auto Trait Implementations§
impl RefUnwindSafe for HTTP_CLIENT
impl Send for HTTP_CLIENT
impl Sync for HTTP_CLIENT
impl Unpin for HTTP_CLIENT
impl UnwindSafe for HTTP_CLIENT
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more