pub struct Request<'a> { /* private fields */ }Expand description
A request to any Kibana route, created by Kibana::request.
Every endpoint builder wraps one of these. Construction never fails;
invalid path segments and serialization errors are returned by send,
with the same variant from every clone. Cloning shares the body, so a
configured request can be reused cheaply, for example per page.
Implementations§
Source§impl<'a> Request<'a>
impl<'a> Request<'a>
Sourcepub fn query<Q: Serialize + ?Sized>(self, query: &Q) -> Self
pub fn query<Q: Serialize + ?Sized>(self, query: &Q) -> Self
Appends URL-encoded query parameters serialized from query.
Avoid adding a second value for an existing selector or other
single-valued parameter; raw query additions do not check for conflicts.
Sourcepub fn json<B: Serialize + ?Sized>(self, body: &B) -> Self
pub fn json<B: Serialize + ?Sized>(self, body: &B) -> Self
Sends body as JSON, replacing any previous body. A body that would
repeat an object key, as when a flattened extension map sets a modeled
field such as id, fails with Error::InvalidRequest.
This is a raw replacement: it does not reapply the named builder’s
selector, concurrency or URL/body identity checks. The caller must
retain those fields. An earlier construction error is still returned
by send, even if the replacement body would be valid.
Sourcepub fn body(self, body: Body) -> Self
pub fn body(self, body: Body) -> Self
Replaces the body without reapplying named-builder checks, as with
Self::json. Earlier construction errors still fail at send.
Sourcepub fn header(self, name: HeaderName, value: HeaderValue) -> Self
pub fn header(self, name: HeaderName, value: HeaderValue) -> Self
Sets a header on this request only. It replaces every value of the same
name from the transport defaults or the body, including Content-Type.
Sourcepub fn request_timeout(self, timeout: Duration) -> Self
pub fn request_timeout(self, timeout: Duration) -> Self
Overrides the transport timeout for this request.
Sourcepub async fn send(self) -> Result<Response>
pub async fn send(self) -> Result<Response>
Sends the request and checks its HTTP status. A successful response’s body
is read separately with Response::json, Response::bytes or a stream.
Construction errors are returned before HTTP. Requests are never retried.