Trait roadrunner::RestClientMethods
[−]
[src]
pub trait RestClientMethods { fn cookie<K, V>(self, name: K, value: V) -> Self where K: Into<Cow<'static, str>>, V: Into<Cow<'static, str>>; fn authorization_basic(self, username: String, password: String) -> Self; fn authorization_bearer(self, token: String) -> Self; fn authorization_string(self, custom: String) -> Self; fn accept(self, media_type: QualityItem<Mime>) -> Self; fn header_set_raw<K>(self, name: K, values: Vec<String>) -> Self where K: Into<Cow<'static, str>>; fn header_append_raw<K>(self, name: K, value: String) -> Self where K: Into<Cow<'static, str>>; fn query_param(self, name: &str, value: &str) -> Self; fn form_field(self, name: &str, value: &str) -> Self; fn json_body_str(self, json_string: String) -> Self; fn json_body_typed<T>(self, typed_value: &T) -> Self where T: Serialize; fn user_agent<K>(self, agent: K) -> Self where K: Into<Cow<'static, str>>; fn user_agent_firefox(self) -> Self; fn user_agent_chrome(self) -> Self; fn execute_on(self, core: &mut Core) -> Result<Response, Error>; }
Provides a high level API that one can use to configure and execute a request.
Required Methods
Set cookie for request, can be called multiple times to set multiple cookies.
Set username and password for basic authentication header.
Set oauth token for oauth authentication.
Set a custom authentication header.
fn accept(self, media_type: QualityItem<Mime>) -> Self
Set Accept header for the request. If none is specified, the default application/json will be used.
fn header_set_raw<K>(self, name: K, values: Vec<String>) -> Self where K: Into<Cow<'static, str>>
Set a header with a raw string, existing value of the same header will be overwritten.
fn header_append_raw<K>(self, name: K, value: String) -> Self where K: Into<Cow<'static, str>>
Append a header with a raw string, existing value of the same header will NOT be overwritten.
fn query_param(self, name: &str, value: &str) -> Self
Append url query parameters.
fn form_field(self, name: &str, value: &str) -> Self
Set form fields for the request. This method can be called multiple times. All fields will be encoded and send as request body.
Note: Content-Type will be set to application/x-www-form-urlencoded.
fn json_body_str(self, json_string: String) -> Self
Set request body as a json string.
Note: Content-Type will be set to application/json.
fn json_body_typed<T>(self, typed_value: &T) -> Self where T: Serialize
Parameter typed_value will be serialized into a json string and sent as the request body.
Note: Content-Type will be set to application/json.
fn user_agent<K>(self, agent: K) -> Self where K: Into<Cow<'static, str>>
Set the user agent header for request. If none is specified,
the default string DEFAULT_USER_AGENT
will be used.
fn user_agent_firefox(self) -> Self
Set the user agent as firefox. This may be needed when a server only accepts requests from well-known user agents.
fn user_agent_chrome(self) -> Self
Set the user agent as chrome.
fn execute_on(self, core: &mut Core) -> Result<Response, Error>
Finish setting up the request, and kick off request execution
on a tokio_core::reactor::Core
.
Implementors
impl RestClientMethods for Result<RestClient, Error>