pub struct HttpRequest {
pub method: Method,
pub url: String,
pub headers: Headers,
pub body: Option<Vec<u8>>,
}Expand description
One outgoing request.
The body is already encoded bytes: encoding is the caller’s decision, and keeping it out of the port means the port never needs to know about JSON, forms or multipart.
Fields§
§method: Method§url: String§headers: Headers§body: Option<Vec<u8>>Implementations§
Source§impl HttpRequest
impl HttpRequest
pub fn new(method: Method, url: impl Into<String>) -> Self
pub fn get(url: impl Into<String>) -> Self
pub fn post(url: impl Into<String>) -> Self
pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
Sourcepub fn bearer(self, token: &str) -> Self
pub fn bearer(self, token: &str) -> Self
Set a bearer token.
Takes the raw string rather than a Secret so that origin-http stays
independent of the credential layer; callers pass token.expose().
pub fn json<T: Serialize>(self, value: &T) -> Result<Self>
Trait Implementations§
Source§impl Clone for HttpRequest
impl Clone for HttpRequest
Source§fn clone(&self) -> HttpRequest
fn clone(&self) -> HttpRequest
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HttpRequest
Redacting Debug: a request body can carry an OAuth code, a refresh token or a
client secret, and a derived Debug would print it verbatim into any log line that
formats a request with ?.
impl Debug for HttpRequest
Redacting Debug: a request body can carry an OAuth code, a refresh token or a
client secret, and a derived Debug would print it verbatim into any log line that
formats a request with ?.
Auto Trait Implementations§
impl Freeze for HttpRequest
impl RefUnwindSafe for HttpRequest
impl Send for HttpRequest
impl Sync for HttpRequest
impl Unpin for HttpRequest
impl UnsafeUnpin for HttpRequest
impl UnwindSafe for HttpRequest
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