Justin (will never dm)
Justin (will never dm)
CDCloudflare Developers
Created by Justin (will never dm) on 9/9/2023 in #🦀rust-on-workers
Modifying Request Host
I tried that but unfortunately I needed to modify the URL. So Kinded needed a
pub fn new_with_str_and_request(
nput: &str,
init: &Request
) -> Result<Request, JsValue>
pub fn new_with_str_and_request(
nput: &str,
init: &Request
) -> Result<Request, JsValue>
which somehow worked in JavaScript. Ended up just writing it in javascript instead 😛 https://github.com/jqphu/shadow-traffic
4 replies
CDCloudflare Developers
Created by Justin (will never dm) on 9/9/2023 in #🦀rust-on-workers
Modifying Request Host
Hmm I think the problem is I don't know how to call the Request constructor with another request object. Like in the example:
const newRequest = new Request(
url.toString(),
new Request(request, newRequestInit)
);
const newRequest = new Request(
url.toString(),
new Request(request, newRequestInit)
);
web_sys::Request does not seem to expose this interface, they all take a RequestInit not a Request (unless there's a way to go from a Request -> RequestInit easily?)
4 replies
CDCloudflare Developers
Created by Justin (will never dm) on 9/9/2023 in #🦀rust-on-workers
Modifying Request Host
Hmm found: https://developers.cloudflare.com/workers/examples/modify-request-property/ Maybe I need to use the underlying web_sys::Request and call web_sys::Request::new_with_str_and_init. Let me see if I can get that to work
4 replies