pub struct RequestParts {
pub method: Method,
pub path: String,
pub query: Option<String>,
pub headers: HeaderMap,
}Expand description
Owned HTTP request metadata extracted from a web_sys::Request.
Workers passes a web_sys::Request with borrowed JS strings and a
ReadableStream body. The gateway expects a RequestInfo that
borrows from Rust-owned data, so this struct bridges the gap by
owning the parsed method, path, query, and headers.
§Example
ⓘ
let (parts, body) = RequestParts::from_web_sys(&req)?;
let result = gateway
.handle_request(&parts.as_request_info(), body, collect_js_body)
.await;Fields§
§method: MethodThe HTTP method.
path: StringThe URL path (e.g. "/bucket/key").
query: Option<String>The raw query string, if present.
headers: HeaderMapThe HTTP request headers.
Implementations§
Source§impl RequestParts
impl RequestParts
Sourcepub fn from_web_sys(req: &Request) -> Result<(Self, JsBody), String>
pub fn from_web_sys(req: &Request) -> Result<(Self, JsBody), String>
Parse a web_sys::Request into owned request metadata and a
zero-copy JsBody.
Extracts the body stream before reading headers, so the
ReadableStream is never locked.
Sourcepub fn as_request_info(&self) -> RequestInfo<'_>
pub fn as_request_info(&self) -> RequestInfo<'_>
Borrow this struct as a RequestInfo for gateway dispatch.
Auto Trait Implementations§
impl Freeze for RequestParts
impl RefUnwindSafe for RequestParts
impl Send for RequestParts
impl Sync for RequestParts
impl Unpin for RequestParts
impl UnsafeUnpin for RequestParts
impl UnwindSafe for RequestParts
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more