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.

Set Accept header for the request. If none is specified, the default application/json will be used.

Set a header with a raw string, existing value of the same header will be overwritten.

Append a header with a raw string, existing value of the same header will NOT be overwritten.

Append url query parameters.

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.

Set request body as a json string.

Note: Content-Type will be set to application/json.

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.

Set the user agent header for request. If none is specified, the default string DEFAULT_USER_AGENT will be used.

Set the user agent as firefox. This may be needed when a server only accepts requests from well-known user agents.

Set the user agent as chrome.

Finish setting up the request, and kick off request execution on a tokio_core::reactor::Core.

Implementors