Crate actix_web[−][src]
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("/{id}/{name}/index.html")] async fn index(path: web::Path<(u32, String)>) -> impl Responder { let (id, name) = path.into_inner(); format!("Hello {}! id:{}", name, id) } #[actix_web::main] async fn main() -> std::io::Result<()> { HttpServer::new(|| App::new().service(index)) .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
- Keep-alive and slow requests handling
- Client/server WebSockets support
- Transparent content compression/decompression (br, gzip, deflate)
- Powerful request routing
- Multipart streams
- Static assets
- SSL support using OpenSSL or Rustls
- Middlewares (Logger, Session, CORS, etc)
- Includes an async HTTP client
- Runs on stable Rust 1.46+
Crate Features
compress
- content encoding compression support (enabled by default)cookies
- cookies support (enabled by default)openssl
- HTTPS support viaopenssl
crate, supportsHTTP/2
rustls
- HTTPS support viarustls
crate, supportsHTTP/2
secure-cookies
- secure cookies support
Re-exports
pub use cookie; | |
pub use crate::error::Result; |
Modules
body | Traits and structures to aid consuming and writing HTTP payloads. |
dev | The |
error | Error and Result module |
guard | Route match guards. |
http | |
middleware | Commonly used middleware. |
rt | Tokio-based single-threaded async runtime for the Actix ecosystem. |
test | Various helpers for Actix applications to use during testing. |
web | Essentials helper functions and types for application registration. |
Macros
services | Macro helping register different types of services at the sametime. |
Structs
App | Application builder - structure that follows the builder pattern for building application instances. |
BaseHttpResponse | An HTTP response. |
Error | General purpose actix web error. |
HttpRequest | An HTTP Request |
HttpResponse | An HTTP Response |
HttpResponseBuilder | An HTTP response builder. |
HttpServer | An HTTP Server. |
Resource | Resource is an entry in resources table which corresponds to requested URL. |
Route | Resource route definition |
Scope | Resources scope. |
Enums
Either | Combines two extractor or responder types into a single type. |
EitherExtractError | A composite error resulting from failure to extract an |
Traits
FromRequest | Trait implemented by types that can be extracted from request. |
HttpMessage | Trait that implements general purpose operations on HTTP messages. |
Responder | Trait implemented by types that can be converted to an HTTP response. |
ResponseError | Errors that can generate responses. |
Attribute Macros
connect | Creates route handler with |
delete | Creates route handler with |
get | Creates route handler with |
head | Creates route handler with |
main | Marks async main function as the actix system entry-point. |
options | Creates route handler with |
patch | Creates route handler with |
post | Creates route handler with |
put | Creates route handler with |
route | Creates resource handler, allowing multiple HTTP method guards. |
trace | Creates route handler with |