Struct django_query::mock::NestedEndpoint
source · [−]pub struct NestedEndpoint<T> { /* private fields */ }
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 it 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/my-bar-id/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 use a UrlTransform to convert any relevant parts of the path into query parameters as required, which is all this type does. It is otherwise identical to Endpoint.
Implementations
sourceimpl<T, R> NestedEndpoint<T> where
T: Send + Sync + RowSource<Item = R>,
R: Filterable + Sortable + 'static,
<T as RowSource>::Rows: Deref,
for<'a> &'a <<T as RowSource>::Rows as Deref>::Target: IntoIterator<Item = &'a R>,
impl<T, R> NestedEndpoint<T> where
T: Send + Sync + RowSource<Item = R>,
R: Filterable + Sortable + 'static,
<T as RowSource>::Rows: Deref,
for<'a> &'a <<T as RowSource>::Rows as Deref>::Target: IntoIterator<Item = &'a R>,
sourcepub fn new(
transform: UrlTransform,
row_source: T,
base_uri: Option<&str>
) -> Self
pub fn new(
transform: UrlTransform,
row_source: T,
base_uri: Option<&str>
) -> Self
Create a new NestedEndpoint.
The given UrlTransform will be applied to every incoming
request. The row_source
will be used to gather the data to
respond to the rewritten request.
Trait Implementations
sourceimpl<T, R> Respond for NestedEndpoint<T> where
T: Send + Sync + RowSource<Item = R>,
R: Filterable + Sortable + IntoRow + 'static,
<T as RowSource>::Rows: Deref,
for<'a> &'a <<T as RowSource>::Rows as Deref>::Target: IntoIterator<Item = &'a R>,
impl<T, R> Respond for NestedEndpoint<T> where
T: Send + Sync + RowSource<Item = R>,
R: Filterable + Sortable + IntoRow + 'static,
<T as RowSource>::Rows: Deref,
for<'a> &'a <<T as RowSource>::Rows as Deref>::Target: IntoIterator<Item = &'a R>,
sourcefn respond(&self, request: &Request) -> ResponseTemplate
fn respond(&self, request: &Request) -> ResponseTemplate
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
impl<T> RefUnwindSafe for NestedEndpoint<T> where
T: RefUnwindSafe,
impl<T> Send for NestedEndpoint<T> where
T: Send,
impl<T> Sync for NestedEndpoint<T> where
T: Sync,
impl<T> Unpin for NestedEndpoint<T> where
T: Unpin,
impl<T> UnwindSafe for NestedEndpoint<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more