pub struct Http<Ev> { /* private fields */ }
Expand description
The Http capability API.
Implementations§
source§impl<Ev> Http<Ev>where
Ev: 'static,
impl<Ev> Http<Ev>where
Ev: 'static,
pub fn new(context: CapabilityContext<HttpRequest, Ev>) -> Self
sourcepub fn get(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
pub fn get(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
Instruct the Shell to perform a HTTP GET request to the provided url
.
The request can be configured via associated functions on RequestBuilder
and then sent with RequestBuilder::send
When finished, the response will be wrapped in an event and dispatched to the app’s `update function.
§Panics
This will panic if a malformed URL is passed.
§Examples
caps.http.get("https://httpbin.org/get").send(Event::ReceiveResponse)
sourcepub fn head(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
pub fn head(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
Instruct the Shell to perform a HTTP HEAD request to the provided url
.
The request can be configured via associated functions on RequestBuilder
and then sent with RequestBuilder::send
When finished, the response will be wrapped in an event and dispatched to the app’s `update function.
§Panics
This will panic if a malformed URL is passed.
§Examples
caps.http.head("https://httpbin.org/get").send(Event::ReceiveResponse)
sourcepub fn post(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
pub fn post(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
Instruct the Shell to perform a HTTP POST request to the provided url
.
The request can be configured via associated functions on RequestBuilder
and then sent with RequestBuilder::send
When finished, the response will be wrapped in an event and dispatched to the app’s `update function.
§Panics
This will panic if a malformed URL is passed.
§Examples
caps.http.post("https://httpbin.org/post").send(Event::ReceiveResponse)
sourcepub fn put(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
pub fn put(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
Instruct the Shell to perform a HTTP PUT request to the provided url
.
The request can be configured via associated functions on RequestBuilder
and then sent with RequestBuilder::send
When finished, the response will be wrapped in an event and dispatched to the app’s `update function.
§Panics
This will panic if a malformed URL is passed.
§Examples
caps.http.put("https://httpbin.org/post").send(Event::ReceiveResponse)
sourcepub fn delete(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
pub fn delete(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
Instruct the Shell to perform a HTTP DELETE request to the provided url
.
The request can be configured via associated functions on RequestBuilder
and then sent with RequestBuilder::send
When finished, the response will be wrapped in an event and dispatched to the app’s `update function.
§Panics
This will panic if a malformed URL is passed.
§Examples
caps.http.delete("https://httpbin.org/post").send(Event::ReceiveResponse)
sourcepub fn connect(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
pub fn connect(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
Instruct the Shell to perform a HTTP CONNECT request to the provided url
.
The request can be configured via associated functions on RequestBuilder
and then sent with RequestBuilder::send
When finished, the response will be wrapped in an event and dispatched to the app’s `update function.
§Panics
This will panic if a malformed URL is passed.
§Examples
caps.http.connect("https://httpbin.org/get").send(Event::ReceiveResponse)
sourcepub fn options(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
pub fn options(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
Instruct the Shell to perform a HTTP OPTIONS request to the provided url
.
The request can be configured via associated functions on RequestBuilder
and then sent with RequestBuilder::send
When finished, the response will be wrapped in an event and dispatched to the app’s `update function.
§Panics
This will panic if a malformed URL is passed.
§Examples
caps.http.options("https://httpbin.org/get").send(Event::ReceiveResponse)
sourcepub fn trace(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
pub fn trace(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
Instruct the Shell to perform a HTTP TRACE request to the provided url
.
The request can be configured via associated functions on RequestBuilder
and then sent with RequestBuilder::send
When finished, the response will be wrapped in an event and dispatched to the app’s `update function.
§Panics
This will panic if a malformed URL is passed.
§Examples
caps.http.trace("https://httpbin.org/get").send(Event::ReceiveResponse)
sourcepub fn patch(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
pub fn patch(&self, url: impl AsRef<str>) -> RequestBuilder<Ev>
Instruct the Shell to perform a HTTP PATCH request to the provided url
.
The request can be configured via associated functions on RequestBuilder
and then sent with RequestBuilder::send
When finished, the response will be wrapped in an event and dispatched to the app’s `update function.
§Panics
This will panic if a malformed URL is passed.
sourcepub fn request(&self, method: Method, url: Url) -> RequestBuilder<Ev>
pub fn request(&self, method: Method, url: Url) -> RequestBuilder<Ev>
Instruct the Shell to perform an HTTP request with the provided method
and url
.
The request can be configured via associated functions on RequestBuilder
and then sent with RequestBuilder::send
When finished, the response will be wrapped in an event and dispatched to the app’s `update function.
Trait Implementations§
Auto Trait Implementations§
impl<Ev> Freeze for Http<Ev>
impl<Ev> !RefUnwindSafe for Http<Ev>
impl<Ev> Send for Http<Ev>
impl<Ev> Sync for Http<Ev>
impl<Ev> Unpin for Http<Ev>
impl<Ev> !UnwindSafe for Http<Ev>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)