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)
5 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.I am pulling my hear out trying to figure out the same thing. Did you ever figure it out, @Chihwei?
@Jeroen
This is work I got, but I can't guarantee it's the most ideal way
ahhh yu're using axum, doesn't quite apply for me
But I figured a few minutes ago that I can use a String as well, but I have to manually type the Response instead of using the built-in one
I turned off the computer though, will try and remember to share for the next victim