Struct elastic::client::RequestParams
[−]
[src]
pub struct RequestParams { pub base_url: String, pub url_params: BTreeMap<&'static str, String>, pub headers: Headers, }
Misc parameters for any request.
The RequestParams
struct allows you to set headers and url parameters for your requests.
By default, the ContentType::json
header will always be added.
Url parameters are added as simple key-value pairs, and serialised by rust-url.
Examples
With default query parameters:
let params = RequestParams::default();
With a custom base url:
let params = RequestParams::new("http://mybaseurl:9200");
With custom headers:
let params = RequestParams::default() .header(Authorization("let me in".to_owned()));
With url query parameters:
let params = RequestParams::default() .url_param("pretty", true) .url_param("q", "*");
Fields
base_url: String
Base url for Elasticsearch.
url_params: BTreeMap<&'static str, String>
Simple key-value store for url query params.
headers: Headers
The complete set of headers that will be sent with the request.
Methods
impl RequestParams
[src]
fn new<T>(base: T) -> RequestParams where
T: Into<String>,
T: Into<String>,
Create a new container for request parameters.
This method takes a fully-qualified url for the Elasticsearch
node.
It will also set the Content-Type
header to application/json
.
fn base_url<T>(self, base: T) -> RequestParams where
T: Into<String>,
T: Into<String>,
Set the base url for the Elasticsearch node.
fn url_param<T>(self, key: &'static str, value: T) -> RequestParams where
T: ToString,
T: ToString,
Set a url param value.
These parameters are added as query parameters to request urls.
fn header<H>(self, header: H) -> RequestParams where
H: Header + HeaderFormat,
H: Header + HeaderFormat,
Set a header value on the params.
fn get_url_qry(&self) -> (usize, Option<String>)
Get the url query params as a formatted string.
Follows the application/x-www-form-urlencoded
format.
This method returns the length of the query string and an optional
value.
If the value is None
, then the length will be 0
.
Trait Implementations
impl Default for RequestParams
[src]
fn default() -> RequestParams
impl Debug for RequestParams
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter.