Struct EasyHttpWebClient

Source
pub struct EasyHttpWebClient<I1 = (), I2 = (), P = NoPool> { /* private fields */ }
Expand description

An opiniated http client that can be used to serve HTTP requests.

You can fork this http client in case you have use cases not possible with this service example. E.g. perhaps you wish to have middleware in into outbound requests, after they passed through your “connector” setup. All this and more is possible by defining your own http client. Rama is here to empower you, the building blocks are there, go crazy with your own service fork and use the full power of Rust at your fingertips ;)

Implementations§

Source§

impl EasyHttpWebClient

Source

pub fn new() -> Self

Create a new EasyHttpWebClient.

Source§

impl<I1, I2, P> EasyHttpWebClient<I1, I2, P>

Source

pub fn set_tls_connector_config( &mut self, layer: TlsConnectorConfig, ) -> &mut Self

Available on crate features rustls or boring only.

Set the [TlsConnectorLayer] of this EasyHttpWebClient.

Source

pub fn with_tls_connector_config(self, layer: TlsConnectorConfig) -> Self

Available on crate features rustls or boring only.

Replace this EasyHttpWebClient with the [TlsConnectorLayer] set.

Source

pub fn maybe_with_tls_connector_config( self, layer: Option<TlsConnectorConfig>, ) -> Self

Available on crate features rustls or boring only.

Replace this EasyHttpWebClient with an option of [TlsConfig] set.

Source

pub fn set_proxy_tls_connector_config( &mut self, layer: TlsConnectorConfig, ) -> &mut Self

Available on crate features rustls or boring only.

Set the [TlsConfig] for the https proxy tunnel if needed within this EasyHttpWebClient.

Source

pub fn with_proxy_tls_connector_config(self, layer: TlsConnectorConfig) -> Self

Available on crate features rustls or boring only.

Replace this EasyHttpWebClient set for the https proxy tunnel if needed within this [TlsConfig].

Source

pub fn maybe_proxy_with_tls_connector_config( self, layer: Option<TlsConnectorConfig>, ) -> Self

Available on crate features rustls or boring only.

Replace this EasyHttpWebClient set for the https proxy tunnel if needed within this [TlsConfig].

Source

pub fn with_proxy_http_connect_version(self, version: Version) -> Self

Set the HTTP version to use for the Http Proxy CONNECT request.

By default this is set to HTTP/1.1.

Source

pub fn set_proxy_http_connect_version(&mut self, version: Version) -> &mut Self

Set the HTTP version to use for the Http Proxy CONNECT request.

Source

pub fn with_proxy_http_connect_auto_version(self) -> Self

Set the HTTP version to auto detect for the Http Proxy CONNECT request.

Source

pub fn set_proxy_http_connect_auto_version(&mut self) -> &mut Self

Set the HTTP version to auto detect for the Http Proxy CONNECT request.

Source

pub fn with_http_conn_req_inspector<T>( self, http_req_inspector: T, ) -> EasyHttpWebClient<T, I2, P>

Available on crate features rustls or boring only.
Source

pub fn with_http_serve_req_inspector<T>( self, http_req_inspector: T, ) -> EasyHttpWebClient<I1, T, P>

Available on crate features rustls or boring only.
Source

pub fn with_connection_pool<T>(self, pool: T) -> EasyHttpWebClient<I1, I2, T>

Available on crate features rustls or boring only.
Source

pub fn without_connection_pool(self) -> EasyHttpWebClient<I1, I2, NoPool>

Available on crate features rustls or boring only.

Trait Implementations§

Source§

impl<I1: Clone, I2: Clone, P: Clone> Clone for EasyHttpWebClient<I1, I2, P>

Available on crate features rustls or boring only.
Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<I1: Debug, I2: Debug, P: Debug> Debug for EasyHttpWebClient<I1, I2, P>

Available on crate features rustls or boring only.
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EasyHttpWebClient

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<State, BodyIn, BodyOut, P, I1, I2> Service<State, Request<BodyIn>> for EasyHttpWebClient<I1, I2, P>
where P: Pool<HttpClientService<BodyOut, I2>, BasicHttpConId, Connection: Service<State, Request<BodyIn>, Response = Response, Error: Into<BoxError> + Unpin + Send + 'static>> + Clone, State: Clone + Send + Sync + 'static, BodyIn: Body<Data: Send + 'static, Error: Into<BoxError>> + Unpin + Send + 'static, BodyOut: Body<Data: Send + 'static, Error: Into<BoxError>> + Unpin + Send + 'static, I1: RequestInspector<State, Request<BodyIn>, Error: Into<BoxError>, StateOut = State, RequestOut = Request<BodyIn>> + Clone, I2: RequestInspector<State, Request<BodyIn>, Error: Into<BoxError>, RequestOut = Request<BodyOut>> + Clone,

Source§

type Response = Response<Body>

The type of response returned by the service.
Source§

type Error = OpaqueError

The type of error returned by the service.
Source§

async fn serve( &self, ctx: Context<State>, req: Request<BodyIn>, ) -> Result<Self::Response, Self::Error>

Serve a response or error for the given request, using the given context.
Source§

fn boxed(self) -> BoxService<S, Request, Self::Response, Self::Error>

Box this service to allow for dynamic dispatch.

Auto Trait Implementations§

§

impl<I1, I2, P> Freeze for EasyHttpWebClient<I1, I2, P>
where P: Freeze, I1: Freeze, I2: Freeze,

§

impl<I1 = (), I2 = (), P = NoPool> !RefUnwindSafe for EasyHttpWebClient<I1, I2, P>

§

impl<I1, I2, P> Send for EasyHttpWebClient<I1, I2, P>
where P: Send, I1: Send, I2: Send,

§

impl<I1, I2, P> Sync for EasyHttpWebClient<I1, I2, P>
where P: Sync, I1: Sync, I2: Sync,

§

impl<I1, I2, P> Unpin for EasyHttpWebClient<I1, I2, P>
where P: Unpin, I1: Unpin, I2: Unpin,

§

impl<I1 = (), I2 = (), P = NoPool> !UnwindSafe for EasyHttpWebClient<I1, I2, P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<State, S, Body> HttpClientExt<State> for S
where S: Service<State, Request<Body>, Response = Response<Body>>, <S as Service<State, Request<Body>>>::Error: Into<Box<dyn Error + Send + Sync>>,

Source§

type ExecuteResponse = Response<Body>

The response type returned by the execute method.
Source§

type ExecuteError = <S as Service<State, Request<Body>>>::Error

The error type returned by the execute method.
Source§

fn get( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, State, <S as HttpClientExt<State>>::ExecuteResponse>

Convenience method to make a GET request to a URL. Read more
Source§

fn post( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, State, <S as HttpClientExt<State>>::ExecuteResponse>

Convenience method to make a POST request to a URL. Read more
Source§

fn put( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, State, <S as HttpClientExt<State>>::ExecuteResponse>

Convenience method to make a PUT request to a URL. Read more
Source§

fn patch( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, State, <S as HttpClientExt<State>>::ExecuteResponse>

Convenience method to make a PATCH request to a URL. Read more
Source§

fn delete( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, State, <S as HttpClientExt<State>>::ExecuteResponse>

Convenience method to make a DELETE request to a URL. Read more
Source§

fn head( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, State, <S as HttpClientExt<State>>::ExecuteResponse>

Convenience method to make a HEAD request to a URL. Read more
Source§

fn request( &self, method: Method, url: impl IntoUrl, ) -> RequestBuilder<'_, S, State, <S as HttpClientExt<State>>::ExecuteResponse>

Start building a Request with the Method and Url. Read more
Source§

fn execute( &self, ctx: Context<State>, request: Request<Body>, ) -> impl Future<Output = Result<<S as HttpClientExt<State>>::ExecuteResponse, <S as HttpClientExt<State>>::ExecuteError>>

Executes a Request. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<S, P, B, E>(self, other: P) -> And<T, P>
where T: Policy<S, B, E>, P: Policy<S, B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<S, P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<S, B, E>, P: Policy<S, B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> RamaInto<U> for T
where U: RamaFrom<T>,

Source§

fn rama_into(self) -> U

Source§

impl<T, U> RamaInto<U> for T
where U: RamaFrom<T>,

Source§

fn rama_into(self) -> U

Source§

impl<T, U> RamaTryInto<U> for T
where U: RamaTryFrom<T>,

Source§

type Error = <U as RamaTryFrom<T>>::Error

Source§

fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T>>::Error>

Source§

impl<T, U> RamaTryInto<U> for T
where U: RamaTryFrom<T>,

Source§

type Error = <U as RamaTryFrom<T>>::Error

Source§

fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T>>::Error>

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,