What is your favorite rust web-framework?

I am currently developing a new IoT-project and we decided to program it in rust since part of the embedded architecture can run the same code as the server side.

mainly the COAP utilizing the 6lowpan for meshing and a classic NFC communication.

I have to design the SaaS parts since I am specialized in HA distributed system architecture.

I am experimenting with:

  • rocket.rs which is a nice framework but it's mainly synchronous. still it has a lot of thought put into it, from an app developer perspective.

  • gotham.rs which is built on top of tokio with hyper - this seams promising since if everything goes well I will need futures anyway and tokio is the defacto standard for complex networking. But it is more flexible which means it's less beginner friendly to use.

I know there are these other frameworks as well arewewebyet.org/topics/frameworks

To make anything but a hip-shot I want some feedback from people who actually built something with those web-frameworks. Even better something on a larger scale.

So what is your current choice for a rust web-framework and why?

Comments (11)

Marco Alka's photo

Never built anything on a large scale, yet, however I checked out Rocket, Gotham and Actix-Web, and of the three, I personally like the last one the most, because it is very maintainable, scalable and can handle requests in parallel easily. It supports many modern things out of the box, like HTTP2, WebSockets, Middleware, etc. It's also built on top of Tokio and once you wrap your head around the actor framework, it's stupidly easy and maintainable (see for example my simple WS server for my Hashnode TM script).

Example:

extern crate actix_web;
use actix_web::{server, App, HttpRequest, Responder};

fn greet(req: &HttpRequest) -> impl Responder {
    let to = req.match_info().get("name").unwrap_or("World");
    format!("Hello {}!", to)
}

fn main() {
    server::new(|| {
        App::new()
            .resource("/", |r| r.f(greet))
            .resource("/{name}", |r| r.f(greet))
    })
    .bind("127.0.0.1:8000")
    .expect("Can not bind to port 8000")
    .run();
}

One of the things I am constantly missing, though, is a way to replace certificates at runtime, so we can use the ACME protocol for Let's Encrypt (or an internal ACME provider). So if anyone encounters a Rust web server framework which supports ACME, cc me :D

Show +8 replies
Marco Alka's photo

j

I don't feel competent enough to write articles

haha, me neither. That's why I write articles. They force me to look things up so I can explain them. Also, people approach me and correct me, which means I can learn from exposing my knowledge and experience. Actually, I never thought my Rust article would be featured. I am quite nervous and self-conscious at the moment, because I feel like I didn't put in enough effort at all.

are you bored

Never, unfortunately. Webpack is really slow and prolly would benefit a lot from some optimization action, though. However, I started porting the Rust game article over to JS, so I will get to WASM articles at some point. Also, the project, which will be my WASM toy (another web server, I can never have enough of those), is opensource. I will inform you as soon as I push anything interesting :)

distributed P2P tools in WASM [..] for science

Sounds like SETI@home?

j's photo

Marco Alka

Sounds like SETI@home?

exactly :) basically en.wikipedia.org/wiki/List_of_distributed_c.. all of them but I think rust would help to keep the memory footprint smaller :) and a lot of people just keep 1 browser window open :) ... but there are ofc dangers withing .... just an idea gg I am way to lazy to follow through.

Actually, I never thought my Rust article would be featured. I am quite nervous and self-conscious at the moment, because I feel like I didn't put in enough effort at all.

I totally get that ;D although I started to let other people from different fields proof read my articles Gg. I am way to lazy with grammar and I forget to establish context for some claims classic failures :). Btw congrats, I've seen the featuring :).

However, I started porting the Rust game article over to JS, so I will get to WASM articles at some point. Also, the project, which will be my WASM toy (another web server, I can never have enough of those), is opensource. I will inform you as soon as I push anything interesting :)

cool I'm looking forward to read more :)