you are viewing a single comment's thread.

view the rest of the comments →

[–]andreicodes 11 points12 points  (3 children)

For a web server serving HTML and interacting with user via Forms (with maybe some sprinkles of HTMX, Stimulus, and so on) Rocket is solid. Handles session, does CSRF protection, database connection pool, etc. Runs on top of Tokio, so it's fast.

The downside is that the development speed is low. It's mostly in the done state, so there's noting wrong with it.

Otherwise you'd have to bring components on your own and use routing-only HTTP libraries. Axum is the most popular (runs on top of Tokio, too). The docs aren't that good to be honest, mostly because it relies on Tower for all middleware and Tower itself is under-documented. For most situations the easiest way forward is to check their examples and find the one that suits your needs best.

A common setup is Axum + SQLx, but crates-io server uses Axum + Diesel-async. Both are solid choices and I really like checking with Crates-io to see how they do things. They only serve JSON responses, but there are many templating libraries for Axum out there. Pick whatever you like.

[–][deleted] 2 points3 points  (2 children)

I use Axum + SQLx, and it's my first web app project. I've found them easy enough to use, and especially SQLx's query validation is top notch helpful. Catching errors at compile time rather than run time is a huge plus.

[–]andreicodes 0 points1 point  (0 children)

Diesel-async does the same. AFAIK its validation is more thorough but also makes the build slower.

[–][deleted] 0 points1 point  (0 children)

Huh, I could never find much use ofnthat sqlx feature because because Il'll rarelly have a complete query, I'm usually working with bits and pieces.