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. - 
HttpRequestandHttpResponse: 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 
awcHTTP 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 viaopensslcrate, supportsHTTP/2rustls- HTTPS support viarustls0.20 crate, supportsHTTP/2rustls-0_21- HTTPS support viarustls0.21 crate, supportsHTTP/2rustls-0_22- HTTPS support viarustls0.22 crate, supportsHTTP/2rustls-0_23- HTTPS support viarustls0.23 crate, supportsHTTP/2secure-cookies- secure cookies support
Re-exports§
pub use crate::error::Error;pub use crate::error::ResponseError;pub use mime;
Modules§
- body
 - Traits and structures to aid consuming and writing HTTP payloads.
 - cookie
 - HTTP cookie parsing and cookie jar management.
 - dev
 - Lower-level types and re-exports.
 - error
 - Error and Result module
 - guard
 - Route guards.
 - http
 - Various HTTP related types.
 - middleware
 - A collection of common middleware.
 - rt
 - A selection of re-exports from 
tokioandactix-rt. - test
 - Various helpers for Actix applications to use during testing.
 - web
 - Essentials helper functions and types for application registration.
 
Macros§
- services
 - Macro to help register different types of services at the same time.
 
Structs§
- App
 - The top-level builder for an Actix Web application.
 - Customize
Responder  - Allows overriding status code and headers (including cookies) for a 
Responder. - Http
Request  - An incoming request.
 - Http
Response  - An outgoing response.
 - Http
Response Builder  - An HTTP response builder.
 - Http
Server  - An HTTP Server.
 - Resource
 - A collection of 
Routes that respond to the same path pattern. - Route
 - A request handler with guards.
 - Scope
 - A collection of 
Routes,Resources, or other services that share a common path prefix. 
Enums§
- Either
 - Combines two extractor or responder types into a single type.
 
Traits§
- From
Request  - A type that implements 
FromRequestis called an extractor and can extract data from the request. Some types that implement this trait are:Json,Header, andPath. - Handler
 - The interface for request handlers.
 - Http
Message  - Trait that implements general purpose operations on HTTP messages.
 - Responder
 - Trait implemented by types that can be converted to an HTTP response.
 
Type Aliases§
Attribute Macros§
- connect
 - Creates route handler with 
actix_web::guard::Connect. - delete
 - Creates route handler with 
actix_web::guard::Delete. - get
 - Creates route handler with 
actix_web::guard::Get. - head
 - Creates route handler with 
actix_web::guard::Head. - main
 - Marks async main function as the Actix Web system entry-point.
 - options
 - Creates route handler with 
actix_web::guard::Options. - patch
 - Creates route handler with 
actix_web::guard::Patch. - post
 - Creates route handler with 
actix_web::guard::Post. - put
 - Creates route handler with 
actix_web::guard::Put. - route
 - Creates resource handler, allowing multiple HTTP method guards.
 - routes
 - Creates resource handler, allowing multiple HTTP methods and paths.
 - scope
 - Prepends a path prefix to all handlers using routing macros inside the attached module.
 - test
 - Marks async test functions to use the Actix Web system entry-point.
 - trace
 - Creates route handler with 
actix_web::guard::Trace.