pub struct Request { /* private fields */ }
Expand description
A Request representation for handling incoming and creating outbound HTTP requests.
Implementations§
source§impl Request
impl Request
sourcepub fn new(uri: &str, method: Method) -> Result<Self>
pub fn new(uri: &str, method: Method) -> Result<Self>
Construct a new Request
with an HTTP Method.
sourcepub fn new_with_init(uri: &str, init: &RequestInit) -> Result<Self>
pub fn new_with_init(uri: &str, init: &RequestInit) -> Result<Self>
Construct a new Request
with a RequestInit
configuration.
sourcepub async fn json<B: DeserializeOwned>(&mut self) -> Result<B>
pub async fn json<B: DeserializeOwned>(&mut self) -> Result<B>
Access this request’s body encoded as JSON.
sourcepub async fn form_data(&mut self) -> Result<FormData>
pub async fn form_data(&mut self) -> Result<FormData>
Access this request’s body as a form-encoded payload and pull out fields and files.
sourcepub fn stream(&mut self) -> Result<ByteStream>
pub fn stream(&mut self) -> Result<ByteStream>
Access this request’s body as a Stream
of bytes.
sourcepub fn headers_mut(&mut self) -> Result<&mut Headers>
pub fn headers_mut(&mut self) -> Result<&mut Headers>
Get a mutable reference to this request’s Headers
.
Note: they can only be modified if the request was created from scratch or cloned.
sourcepub fn cf(&self) -> Option<&Cf>
pub fn cf(&self) -> Option<&Cf>
Access this request’s Cloudflare-specific properties.
§Note
Request objects constructed by the user and not the runtime will not have a Cf associated.
See workerd#825
sourcepub fn path_mut(&mut self) -> Result<&mut String>
pub fn path_mut(&mut self) -> Result<&mut String>
Get a mutable reference to this request’s path. Note: they can only be modified if the request was created from scratch or cloned.
sourcepub fn query<Q: DeserializeOwned>(&self) -> Result<Q>
pub fn query<Q: DeserializeOwned>(&self) -> Result<Q>
Deserialize the url query