Expand description
Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.
Examples
use actix_web::{get, web, App, HttpServer, Responder};
#[get("/hello/{name}")]
async fn greet(name: web::Path<String>) -> impl Responder {
format!("Hello {}!", name)
}
#[actix_web::main] // or #[tokio::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new().service(greet)
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}
Documentation & Community Resources
In addition to this API documentation, several other resources are available:
To get started navigating the API docs, you may consider looking at the following pages first:
-
App
: This struct represents an Actix Web application and is used to configure routes and other common application settings. -
HttpServer
: This struct represents an HTTP server instance and is used to instantiate and configure servers. -
web
: This module provides essential types for route registration as well as common utilities for request handlers. -
HttpRequest
andHttpResponse
: These structs represent HTTP requests and responses and expose methods for creating, inspecting, and otherwise utilizing them.
Features
- Supports HTTP/1.x and HTTP/2
- Streaming and pipelining
- Powerful request routing with optional macros
- Full Tokio compatibility
- Keep-alive and slow requests handling
- Client/server WebSockets support
- Transparent content compression/decompression (br, gzip, deflate, zstd)
- Multipart streams
- Static assets
- SSL support using OpenSSL or Rustls
- Middlewares (Logger, Session, CORS, etc)
- Integrates with the
awc
HTTP client - Runs on stable Rust 1.54+
Crate Features
cookies
- cookies support (enabled by default)macros
- routing and runtime macros (enabled by default)compress-brotli
- brotli content encoding compression support (enabled by default)compress-gzip
- gzip and deflate content encoding compression support (enabled by default)compress-zstd
- zstd content encoding compression support (enabled by default)openssl
- HTTPS support viaopenssl
crate, supportsHTTP/2
rustls
- HTTPS support viarustls
crate, supportsHTTP/2
secure-cookies
- secure cookies support
Modules
cookies
Macros
Structs
Responder
.Enums
Traits
FromRequest
is called an extractor and can extract data from
the request. Some types that implement this trait are: Json
, Header
, and Path
.Type Definitions
Attribute Macros
macros
actix_web::guard::Connect
.macros
actix_web::guard::Delete
.macros
actix_web::guard::Get
.macros
actix_web::guard::Head
.macros
macros
actix_web::guard::Options
.macros
actix_web::guard::Patch
.macros
actix_web::guard::Post
.macros
actix_web::guard::Put
.macros
macros
macros
macros
actix_web::guard::Trace
.