pub struct RequestBuilder { /* private fields */ }
Expand description
A builder for non-streaming outgoing HTTP requests. You can obtain a RequestBuilder from the Request::builder() method, or from method-specific helpers such as Request::get() or Request::post().
§Examples
Use a method helper to build an outgoing POST request:
use spin_sdk::http::{Request, Response};
let request = Request::post("https://example.com", "it's a-me, Spin")
.header("content-type", "text/plain")
.build();
let response: Response = spin_sdk::http::send(request).await?;
Build and send an outgoing request using the RequestBuilder.
use spin_sdk::http::{Method, Request, Response};
let request = Request::builder()
.uri("https://example.com/message/motivational")
.method(Method::Put)
.header("content-type", "text/plain")
.body("the capybaras of creativity fly higher than the bluebirds of banality")
.build();
let response: Response = spin_sdk::http::send(request).await?;
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RequestBuilder
impl RefUnwindSafe for RequestBuilder
impl Send for RequestBuilder
impl Sync for RequestBuilder
impl Unpin for RequestBuilder
impl UnwindSafe for RequestBuilder
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
Mutably borrows from an owned value. Read more