pub trait HttpClientExt<State>: HttpClientExtSealed<State> + Sized + Send + Sync + 'static {
    type ExecuteResponse;
    type ExecuteError;

    // Required methods
    fn get(
        &self,
        url: impl IntoUrl
    ) -> RequestBuilder<'_, Self, State, Self::ExecuteResponse>;
    fn post(
        &self,
        url: impl IntoUrl
    ) -> RequestBuilder<'_, Self, State, Self::ExecuteResponse>;
    fn put(
        &self,
        url: impl IntoUrl
    ) -> RequestBuilder<'_, Self, State, Self::ExecuteResponse>;
    fn patch(
        &self,
        url: impl IntoUrl
    ) -> RequestBuilder<'_, Self, State, Self::ExecuteResponse>;
    fn delete(
        &self,
        url: impl IntoUrl
    ) -> RequestBuilder<'_, Self, State, Self::ExecuteResponse>;
    fn head(
        &self,
        url: impl IntoUrl
    ) -> RequestBuilder<'_, Self, State, Self::ExecuteResponse>;
    fn request(
        &self,
        method: Method,
        url: impl IntoUrl
    ) -> RequestBuilder<'_, Self, State, Self::ExecuteResponse>;
    fn execute(
        &self,
        ctx: Context<State>,
        request: Request
    ) -> impl Future<Output = Result<Self::ExecuteResponse, Self::ExecuteError>>;
}
Expand description

Extends an Http Client with high level features, to facilitate the creation and sending of http requests, in a more ergonomic way.

Required Associated Types§

source

type ExecuteResponse

The response type returned by the execute method.

source

type ExecuteError

The error type returned by the execute method.

Required Methods§

source

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

Convenience method to make a GET request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

source

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

Convenience method to make a POST request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

source

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

Convenience method to make a PUT request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

source

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

Convenience method to make a PATCH request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

source

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

Convenience method to make a DELETE request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

source

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

Convenience method to make a HEAD request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

source

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

Start building a Request with the Method and Url.

Returns a RequestBuilder, which will allow setting headers and the request body before sending.

§Errors

This method fails whenever the supplied Url cannot be parsed.

source

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

Executes a Request.

§Errors

This method fails if there was an error while sending request.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<State, S, Body> HttpClientExt<State> for S
where S: Service<State, Request, Response = Response<Body>>, S::Error: Into<BoxError>,

§

type ExecuteResponse = Response<Body>

§

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