[−][src]Trait http_endpoint::Endpoint
A trait describing an HTTP endpoint.
An endpoint for our intents and purposes is basically a path and an
HTTP request method (e.g., GET or POST). The path will be combined
with an "authority" (scheme, host, and port) into a full URL. Query
parameters are supported as well.
An endpoint is used by the Trader
who invokes the various methods.
Associated Types
type Input
The type of data being passed in as part of a request to this endpoint.
type Output: DeserializeOwned
The type of data being returned in the response from this endpoint.
type Error: Debug + Display + Error + From<HttpError> + From<JsonError> + 'static
The type of error this endpoint can report.
type ApiError: DeserializeOwned + Display
An error emitted by the API.
Required methods
Loading content...Provided methods
fn base_url() -> Option<Str>
Retrieve the base URL to use.
By default no URL is provided for the endpoint, in which case it is the client's responsibility to supply one.
fn method() -> Method
Retrieve the HTTP method to use.
The default method being used is GET.
fn query(input: &Self::Input) -> Option<Str>
Inquire the query the request should use.
By default no query is emitted.
fn body(input: &Self::Input) -> Result<Bytes, JsonError>
Retrieve the request's body.
By default this method creates an empty body.
fn parse(body: &[u8]) -> Result<Self::Output, Self::Error>
Parse the body into the final result.
By default this method directly parses the body as JSON.
fn parse_err(body: &[u8]) -> Result<Self::ApiError, Vec<u8>>
Parse an API error.