Hacker News new | ask | show | jobs
by djrenren 946 days ago
After using Rocket in production for a year now. I'd really recommend Actix Web. Don't get me wrong, Rocket has some really nice features and good UI, but a couple things have proved to be real pain points:

- Middleware ("fairings" in rocket parlance) can't respond to requests. This means your access control has to be replicated on every route as a guard.

- Guards can result in errors (for example, if the request doesn't have a valid Auhorization header), but you can't set the response body without a nasty workaround that causes other issues [1]

- Guards also have tricky performance gotchas. When multiple handlers match the same route, rocket will try them all in priority order. Often these variants have the same or similar sets of guards, but guards don't cache by default. Doing your own caching gets tricky especially in the presence of workaround [1].

All this to say, Rocket works well, but it has some unique problems that come from its early design decisions (e.g. the guard error messages which has an open issue) and some from ongoing decisions (i.e. the project seems to committed to the fairing model over standard middleware).

Many of these problems are fixable by community members like you, but actix avoids several of these and has a larger developer base. I've heard good things about axum and the docs look great but I haven't had much experience so I can't offer a strong recommendation.

[1]: https://github.com/rwf2/Rocket/issues/749#issuecomment-91629...

2 comments

The first two points will be addressed in the next major release with typed catchers. The latest release notes[1] call this out, and in fact reference the same Github issue.

Additionally, it looks like they're even addressing one of the most common criticisms - having to declare requirements/guards on every handler. See "Associated Resources".

[1]: https://rocket.rs/v0.5/news/2023-11-17-version-0.5/

Really cool to see these issues are on the roadmap.

I remain skeptical on timeline for these but if the plans speed up dev time work out, then this is great news.

>Middleware ("fairings" in rocket parlance)

I really hate it when libraries introduce their own nomenclature for the sake of being cutesy.

And ironically its not even a great word to describe what its use is
But honestly, “middleware”? That was already taken years ago, long before the web took off. In fact, it was first used before the web was even invented!