rust's powerful actor system and most fun web framework
Forget about stringly typed objects, from request to response, everything has types.
Actix provides a lot of features out of box. WebSockets, HTTP/2, pipelining etc.
Easily create your own libraries that any Actix application can use.
Actix is blazingly fast. Check yourself.
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();
}
Handler functions in actix can return a wide range of objects that
implement the Responder trait. This makes it a breeze
to return consistent responses from your APIs.
#[derive(Serialize)]
struct Measurement {
temperature: f32,
}
fn hello_world() -> impl Responder {
"Hello World!"
}
fn current_temperature(_req: HttpRequest) -> impl Responder {
Json(Measurement { temperature: 42.3 })
}