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.