pub struct NestedEndpoint<T> { /* private fields */ }
wiremock
only.Expand description
A Django nested route.
A nested route in Django is a way of specifying that a particular
filter field must be present when querying for a particular object
type, and that the filter type must be exact match. So for
example, if all objects of type Foo
have a reference to a Bar
,
and its too expensive or undesirable to query for Foo
s without
specifying which Bar
they come from, then you can express this
in Django as a nested route:
http://example.com/bars/1/foos
where in order to ask any question about Foo
s you must first
identify a particular associated Bar
.
Since the django-query crate operates on query parameters, the
simplest way to handle this is to convert any relevant parts of
the path into query parameters as required, which is all this type
does. See its construction parameters NestedEndpointParams
for
the details. This type is otherwise identical to Endpoint
.
Implementations§
Source§impl<'q, T> NestedEndpoint<T>
impl<'q, T> NestedEndpoint<T>
Sourcepub fn new(row_source: T, p: NestedEndpointParams<'_>) -> Self
pub fn new(row_source: T, p: NestedEndpointParams<'_>) -> Self
Create a new NestedEndpoint
.
The arguments to this function are wrapped in their own
structure: NestedEndpointParams
.
Sourcepub fn default_limit(&mut self, limit: usize)
pub fn default_limit(&mut self, limit: usize)
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§
Source§impl<'q, T> Respond for NestedEndpoint<T>
impl<'q, T> Respond for NestedEndpoint<T>
Source§fn respond(&self, request: &Request) -> ResponseTemplate
fn respond(&self, request: &Request) -> ResponseTemplate
Request
return a ResponseTemplate
that will be used
by the MockServer
as blueprint for the response returned to the client.