{{ partial "header" . }}

rust's powerful actor system and most fun web framework

Type Safe

Forget about stringly typed objects, from request to response, everything has types.

Feature Rich

Actix provides a lot of features out of box. WebSockets, HTTP/2, pipelining etc.

Extensible

Easily create your own libraries that any Actix application can use.

Blazingly Fast

Actix is blazingly fast. Don't take our word for it -- see for yourself!

{{ highlight `use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer}; fn greet(req: HttpRequest) -> HttpResponse { let name = req.match_info().get("name").unwrap_or("World"); HttpResponse::Ok().body(format!("Hello {}!", &name)) } fn main() { HttpServer::new(|| { App::new() .service(web::resource("/").to(greet)) .service(web::resource("/{name}").to(greet)) }) .bind("127.0.0.1:8000") .expect("Can not bind to port 8000") .run() .unwrap(); }` "rust" "" }}

Flexible Responders

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.

{{ highlight `#[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 }) }` "rust" "" }}

Powerful Extractors

Actix comes with a powerful extractor system that extracts data from the incoming HTTP request and passes it to your view functions. Not only does this make for a convenient API but it also means that your view functions can be synchronous code and still benefit from asynchronous IO handling.

{{ highlight `#[derive(Deserialize, Serialize)] struct Event { id: Option, timestamp: f64, kind: String, tags: Vec, } fn capture_event(evt: web::Json) -> actix_web::Result { let new_event = store_event_in_db(evt.timestamp, evt.kind.clone(), evt.tags.clone()); Ok(HttpResponse::Ok().json(new_event)) }` "rust" "" }}

Easy Form Handling

Handling multipart/urlencoded form data is easy. Just define a structure that can be deserialized and actix will handle the rest.

{{ highlight `#[derive(Deserialize)] struct Register { username: String, country: String, } fn register(params: web::Form) -> actix_web::Result { Ok(HttpResponse::Ok().body(format!( "Hello {} from {}!", params.username, params.country ))) }` "rust" "" }}

Request Routing

An actix app comes with a URL routing system that lets you match on URLs and invoke individual handlers. For extra flexibility, scopes can be used.

{{ highlight `fn index(_req: HttpRequest) -> HttpResponse { HttpResponse::Ok().body("Hello from the index page!") } fn hello(path: web::Path) -> HttpResponse { HttpResponse::Ok().body(format!("Hello {}!", &path)) } fn main() { App::new() .route("/", web::get().to(index)) .route("/{name}", web::get().to(hello)); }` "rust" "" }}
{{ partial "footer" . }}