pub struct EndpointWithContext<T> where
    T: Send + Sync + RowSource,
    for<'t> &'t <<T as RowSource>::Rows as RowSet>::Target: IntoIterator<Item = &'t <T as RowSource>::Item>, 
{ /* private fields */ }
Available on crate feature wiremock only.
Expand description

A Django-style endpoint for a collection of objects that require a context value.

EndpointWithContext implements wiremock::Respond and so can be mounted directly into a wiremock::MockServer. It contains a RowSource which it will query for a fresh data on each query.

The primary distinction between this type and Endpoint is that it can be used with types that require a context object, and so relies on the extended traits FilterableWithContext, IntoRowWithContext and SortableWithContext.

Any supplied RowSource needs to generate RowSet values that double as the context value required by these traits.

Implementations

Create a new EndpointWithContext.

row_source is where the data comes from. base_uri, if provided, should be the wiremock server URI.

base_uri is only required because wiremock mangles the request URL such that it’s not possible to inspect it to see how to give out other URLs on the same server; the port number, which is usually random when mocking, is lost. Since Django includes full absolute URLs for the next and preceding pages for a query, mimicking this is impossible without more information (i.e. including usable URLs for the next page within the query response is impossible).

Set the default number of results returned

This is the value used when no limit is specified in the query. This value is configurable in Django; the default behaviour of this mock endpoint is to return everything, but that makes testing code that uses the default pagination more difficult.

Trait Implementations

Given a reference to a Request return a ResponseTemplate that will be used by the MockServer as blueprint for the response returned to the client. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

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

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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