pub struct RequestParts {
pub method: Method,
pub path: String,
pub signing_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 percent-decoded URL path (e.g. "/bucket/my key").
Decoded for S3 operation parsing and bucket/key routing. Do not use
this for SigV4 verification: the canonical URI must be the encoded form
the client signed, so use signing_path instead.
signing_path: StringThe raw, percent-encoded URL path exactly as it arrived on the wire
(e.g. "/bucket/my%20key").
This is the form the client signs, so it is what SigV4 verification must
canonicalize over. as_request_info wires it
into RequestInfo’s signing path automatically. Integrators that
rewrite paths before dispatch (e.g. path-mapping) must still sign against
this encoded path — never the decoded path.
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.
Sets the signing path to the raw, percent-encoded
signing_path so SigV4 verification canonicalizes
over the path the client actually signed. Without this, a key containing
a character the client escapes — e.g. a space → %20 — would be verified
against the decoded path and fail with SignatureDoesNotMatch.
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
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>
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>
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