Answering HTTP requests

Within a larger program, I need to listen to incoming HTTP requests when a certain command line option is given. I wonder which crate I could use to open a port and listen to HTTP requests. Which one is recommended?

I've seen there is Actix Web, but I guess this is a larger framework?

Note that my main program isn't async per-se, but I wouldn't have a problem to spawn an async runtime for the purpose of the web server. I guess I can still use Actix Web in that case?

Any alternatives, or what are the recommendations?


After skimming through the docs, I feel like I could make Actix Web work for my purposes. Nonetheless, I would like to rephrase my question:

Are there any other crates in regard to handling HTTP requests, server side, which are worth taking into consideration?

A more bare-bones library is (the server half of) hyper. actix-web and tide apparently roll their own HTTP server implementations, but the other major "web application frameworks" I'm aware of, namely axum, rocket, and warp, all build on hyper, adding various features and conveniences that may or may not be useful in your case.

You can also stick routerify on top of hyper for something higher-level but short of a web framework.

If you don't care about async, there's tiny_http, and rouille which builds atop it.

6 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.