[][src]Struct anneal::RequestBuilder

pub struct RequestBuilder { /* fields omitted */ }

Methods

impl RequestBuilder[src]

pub fn new<U: IntoUrl>(
    method: Method,
    url: U
) -> Result<RequestBuilder, ParseError>
[src]

Create a new request builder with the given method and url

An error will be returned if the url fails to parse

pub fn get<U: IntoUrl>(url: U) -> Result<RequestBuilder, ParseError>[src]

Shorthand for RequestBuilder::new(Method::Get, url)

pub fn post<U: IntoUrl>(url: U) -> Result<RequestBuilder, ParseError>[src]

Shorthand for RequestBuilder::new(Method::Post, url)

pub fn options<U: IntoUrl>(url: U) -> Result<RequestBuilder, ParseError>[src]

Shorthand for RequestBuilder::new(Method::Options, url)

pub fn put<U: IntoUrl>(url: U) -> Result<RequestBuilder, ParseError>[src]

Shorthand for RequestBuilder::new(Method::Put, url)

pub fn delete<U: IntoUrl>(url: U) -> Result<RequestBuilder, ParseError>[src]

Shorthand for RequestBuilder::new(Method::Delete, url)

pub fn head<U: IntoUrl>(url: U) -> Result<RequestBuilder, ParseError>[src]

Shorthand for RequestBuilder::new(Method::Head, url)

pub fn trace<U: IntoUrl>(url: U) -> Result<RequestBuilder, ParseError>[src]

Shorthand for RequestBuilder::new(Method::Trace, url)

pub fn connect<U: IntoUrl>(url: U) -> Result<RequestBuilder, ParseError>[src]

Shorthand for RequestBuilder::new(Method::Connect, url)

pub fn patch<U: IntoUrl>(url: U) -> Result<RequestBuilder, ParseError>[src]

Shorthand for RequestBuilder::new(Method::Patch, url)

pub fn default_post() -> Self[src]

Builds a POST request to http://127.0.0.1:8080/

pub fn set_header<H: Header + HeaderFormat>(&mut self, header: H) -> &mut Self[src]

Set an individual header

pub fn set_headers(&mut self, headers: Headers) -> &mut Self[src]

Replace the headers with a new Headers struct

pub fn set_url<U: IntoUrl>(&mut self, url: U) -> Result<&mut Self, ParseError>[src]

Change the destination url of this request

pub fn set_method(&mut self, method: Method) -> &mut Self[src]

Change this request's method

pub fn set_bytes(&mut self, body: Vec<u8>) -> &mut Self[src]

Set the body of the request to the provided vec

pub fn set_string(&mut self, body: &str) -> &mut Self[src]

Set the body of the request to the provided string

pub fn add_middleware<B: BeforeMiddleware + 'static>(
    &mut self,
    middleware: B
) -> &mut Self
[src]

Add BeforeMiddleware to be run before the main handler

This adds middleware after all that is currently on the chain. If the middleware in this chain fails while building a request the request will panic.

pub fn set_chain(&mut self, chain: Vec<Box<dyn BeforeMiddleware>>) -> &mut Self[src]

Set the middleware chain to be run before the main handler

pub fn set_cookies(&mut self, cookies: &CookieJar) -> &mut Self[src]

Set the Cookie header of the request

pub fn set_json<T: Serialize>(&mut self, json: &T) -> &mut Self[src]

Set the main body of the request to contain serialized json

This also sets the Content-Type header to application/json

pub fn request<T, H: FnOnce(Request) -> T>(&self, handler: H) -> T[src]

Generate a request and hand it off to some handler function

This will panic if any of the middleware in the before chain fails

The return value of the handler function will be return value of this function

pub fn request_response<H: FnOnce(Request) -> IronResult<Response>>(
    &self,
    handler: H
) -> IronResult<ResponseExamine>
[src]

Generate a request and hand it off to a handler function, mapping the response into a ResponseExamine for easier checking

Trait Implementations

impl Default for RequestBuilder[src]

Builds a GET request to http://127.0.0.1:8080/

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

impl<T> UnsafeAny for T where
    T: Any