crux_http::command

Struct Http

Source
pub struct Http<Effect, Event> { /* private fields */ }

Implementations§

Source§

impl<Effect, Event> Http<Effect, Event>
where Effect: Send + From<Request<HttpRequest>> + 'static, Event: Send + 'static,

Source

pub fn get(url: impl AsRef<str>) -> RequestBuilder<Effect, Event>

Instruct the Shell to perform a HTTP GET request to the provided url.

The request can be configured via associated functions on the returned RequestBuilder and then converted to a [Command] with RequestBuilder::build.

§Panics

This will panic if a malformed URL is passed.

§Examples
Http::get("https://httpbin.org/get")
    .expect_string()
    .build()
    .then_send(Event::ReceiveResponse);
Source

pub fn head(url: impl AsRef<str>) -> RequestBuilder<Effect, Event>

Instruct the Shell to perform a HTTP HEAD request to the provided url.

The request can be configured via associated functions on the returned RequestBuilder and then converted to a [Command] with RequestBuilder::build.

§Panics

This will panic if a malformed URL is passed.

§Examples
Http::head("https://httpbin.org/get")
    .build()
    .then_send(Event::ReceiveResponse);
Source

pub fn post(url: impl AsRef<str>) -> RequestBuilder<Effect, Event>

Instruct the Shell to perform a HTTP POST request to the provided url.

The request can be configured via associated functions on the returned RequestBuilder and then converted to a [Command] with RequestBuilder::build.

§Panics

This will panic if a malformed URL is passed.

§Examples
Http::post("https://httpbin.org/post")
    .body_bytes(b"hello_world".to_owned())
    .build()
    .then_send(Event::ReceiveResponse);
Source

pub fn put(url: impl AsRef<str>) -> RequestBuilder<Effect, Event>

Instruct the Shell to perform a HTTP PUT request to the provided url.

The request can be configured via associated functions on the returned RequestBuilder and then converted to a [Command] with RequestBuilder::build.

§Panics

This will panic if a malformed URL is passed.

§Examples
Http::put("https://httpbin.org/put")
    .body_string("hello_world".to_string())
    .build()
    .then_send(Event::ReceiveResponse);
Source

pub fn delete(url: impl AsRef<str>) -> RequestBuilder<Effect, Event>

Instruct the Shell to perform a HTTP DELETE request to the provided url.

The request can be configured via associated functions on the returned RequestBuilder and then converted to a [Command] with RequestBuilder::build.

§Panics

This will panic if a malformed URL is passed.

§Examples
Http::delete("https://httpbin.org/delete")
    .build()
    .then_send(Event::ReceiveResponse);
Source

pub fn patch(url: impl AsRef<str>) -> RequestBuilder<Effect, Event>

Instruct the Shell to perform a HTTP PATCH request to the provided url.

The request can be configured via associated functions on the returned RequestBuilder and then converted to a [Command] with RequestBuilder::build.

§Panics

This will panic if a malformed URL is passed.

§Examples
Http::patch("https://httpbin.org/patch")
    .body_form(&[("name", "Alice")]).unwrap()
    .build()
    .then_send(Event::ReceiveResponse);
Source

pub fn options(url: impl AsRef<str>) -> RequestBuilder<Effect, Event>

Instruct the Shell to perform a HTTP OPTIONS request to the provided url.

The request can be configured via associated functions on the returned RequestBuilder and then converted to a [Command] with RequestBuilder::build.

§Panics

This will panic if a malformed URL is passed.

§Examples
Http::options("https://httpbin.org/get")
    .build()
    .then_send(Event::ReceiveResponse);
Source

pub fn trace(url: impl AsRef<str>) -> RequestBuilder<Effect, Event>

Instruct the Shell to perform a HTTP TRACE request to the provided url.

The request can be configured via associated functions on the returned RequestBuilder and then converted to a [Command] with RequestBuilder::build.

§Panics

This will panic if a malformed URL is passed.

§Examples
Http::trace("https://httpbin.org/get")
    .build()
    .then_send(Event::ReceiveResponse);
Source

pub fn connect(url: impl AsRef<str>) -> RequestBuilder<Effect, Event>

Instruct the Shell to perform a HTTP CONNECT request to the provided url.

The request can be configured via associated functions on the returned RequestBuilder and then converted to a [Command] with RequestBuilder::build.

§Panics

This will panic if a malformed URL is passed.

§Examples
Http::connect("https://httpbin.org/get")
    .build()
    .then_send(Event::ReceiveResponse);
Source

pub fn request(method: Method, url: Url) -> RequestBuilder<Effect, Event>

Instruct the Shell to perform an HTTP request to the provided url.

The request can be configured via associated functions on the returned RequestBuilder and then converted to a [Command] with RequestBuilder::build.

§Panics

This will panic if a malformed URL is passed.

§Examples
Http::request(Method::Post, "https://httpbin.org/post".parse().unwrap())
    .body_form(&[("name", "Alice")]).unwrap()
    .build()
    .then_send(Event::ReceiveResponse);

Auto Trait Implementations§

§

impl<Effect, Event> Freeze for Http<Effect, Event>

§

impl<Effect, Event> RefUnwindSafe for Http<Effect, Event>
where Effect: RefUnwindSafe, Event: RefUnwindSafe,

§

impl<Effect, Event> Send for Http<Effect, Event>
where Effect: Send, Event: Send,

§

impl<Effect, Event> Sync for Http<Effect, Event>
where Effect: Sync, Event: Sync,

§

impl<Effect, Event> Unpin for Http<Effect, Event>
where Effect: Unpin, Event: Unpin,

§

impl<Effect, Event> UnwindSafe for Http<Effect, Event>
where Effect: UnwindSafe, Event: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T