worker-rs: http hello world
How can I put a simple string into the body? Tried many ways but didn't work. The body seems to be only accepting a stream. (http feature flag enabled for worker-rs)
2 Replies
Response::ok("Hello, World!")
, You should see example of using workers rs (https://github.com/cloudflare/workers-rs/blob/main/examples/, https://developers.cloudflare.com/workers/languages/rust/#3-write-your-worker-code)Cloudflare Docs
Cloudflare Workers — Rust language support · Cloudflare Workers doc...
Write Workers in 100% Rust using the
workers-rs
crateThanks! Most of those examples are not with
http
feature flag turned on, which they are using older Response defined in worker-rs
, rather than more widely used rust http
crate. I later found I could change the wrapped type of Result
to assign it a string, like Result<String>
. I am a beginner of Rust, so let me know if I was wrong on anything.