💾 Archived View for a.rusty-haiku.dev › posts › 2022-06-07-http-tides.gmi captured on 2023-09-08 at 15:55:13. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-06-11)
-=-=-=-=-=-=-
2022-06-07
After poking around a little more I found another http crate that shows promise with Haiku.
This one is called tide [1]
Tide builds cleanly under Haiku with just a simple git clone then cargo build which is my (lazy) litmus test to see how easy it is to use any particular Rust crate on Haiku. Usually, it tends to be a dependency like the grumpy mio crate which is usually pulled in as part of the tokio dependency toolchain. If it's mio, then you're out of luck [2] for the time being. Note that it IS possible, to use the tokio crate in such a way that the mio dependency does not have to be activated. However, from passive observation of crates in the wild, it will more likely bring in the mio dependency which will most likely cause builds to fail.
While the crate itself builds cleanly, it seems that the hello example requires a little fiddling in order to get running, because when I try to build th example I see the following:
> git clone https://github.com/http-rs/tide > cd tide tide> cargo build --example hello ... (elided) error[E0425]: cannot find function `start` in module `tide::log` --> examples/hello.rs:3:16 | 3 | tide::log::start(); | ^^^^^ not found in `tide::log` | = note: consider importing this function:
Well that is kind of inconvenient. To work around this I ended up just disabling the offending line (comment out line 3) and trying a build again, we get a running hello program and try to run it
tide> cargo build --example hello ... ... (lots more elided) ... Finished dev [unoptimized + debuginfo] target(s) in 4m 41s tide> ls -lh target/debug/examples/hello -rwxr-xr-x 1 user root 62M Jun 6 23:55 target/debug/examples/hello tide> target/debug/examples/hello
Now in another terminal window, go ahead and make that http request to the hello server. (Ignore that echo)
> curl http://localhost:8080/; echo "" Hello, world!
And we can see that tide crate (with some small caveats) is ready to handle http for Haiku.
[1] https://github.com/http-rs/tide
[2] https://github.com/tokio-rs/mio/issues/1472