worker_sys/ext/
request.rs1use wasm_bindgen::prelude::*;
2
3use crate::types::IncomingRequestCfProperties;
4
5mod glue {
6 use super::*;
7
8 #[wasm_bindgen]
9 extern "C" {
10 #[wasm_bindgen]
11 pub type Request;
12
13 #[wasm_bindgen(method, catch, getter)]
14 pub fn cf(this: &Request) -> Result<Option<IncomingRequestCfProperties>, JsValue>;
15 }
16}
17
18pub trait RequestExt {
19 fn cf(&self) -> Option<IncomingRequestCfProperties>;
21}
22
23impl RequestExt for web_sys::Request {
24 fn cf(&self) -> Option<IncomingRequestCfProperties> {
25 self.unchecked_ref::<glue::Request>().cf().unwrap()
26 }
27}