[−][src]Crate actix_web
Actix web is a small, pragmatic, and extremely fast web framework for Rust.
use actix_web::{web, App, Responder, HttpServer}; async fn index(info: web::Path<(String, u32)>) -> impl Responder { format!("Hello {}! id:{}", info.0, info.1) } #[actix_rt::main] async fn main() -> std::io::Result<()> { HttpServer::new(|| App::new().service( web::resource("/{name}/{id}/index.html").to(index)) ) .bind("127.0.0.1:8080")? .run() .await }
Documentation & community resources
Besides the API documentation (which you are currently looking at!), several other resources are available:
To get started navigating the API documentation you may want to consider looking at the following pages:
-
App: This struct represents an actix-web application and is used to configure routes and other common settings.
-
HttpServer: This struct represents an HTTP server instance and is used to instantiate and configure servers.
-
web: This module provides essential helper functions and types for application registration.
-
HttpRequest and HttpResponse: These structs represent HTTP requests and responses and expose various methods for inspecting, creating and otherwise utilizing them.
Features
- Supported HTTP/1.x and HTTP/2.0 protocols
- Streaming and pipelining
- Keep-alive and slow requests handling
WebSockets
server/client- Transparent content compression/decompression (br, gzip, deflate)
- Configurable request routing
- Multipart streams
- SSL support with OpenSSL or
native-tls
- Middlewares (
Logger
,Session
,CORS
,DefaultHeaders
) - Supports Actix actor framework
- Supported Rust version: 1.39 or later
Package feature
client
- enables http client (default enabled)compress
- enables content encoding compression support (default enabled)openssl
- enables ssl support viaopenssl
crate, supportshttp/2
rustls
- enables ssl support viarustls
crate, supportshttp/2
secure-cookies
- enables secure cookies support, includesring
crate as dependency
Modules
body | |
client | An HTTP Client |
cookie | https://github.com/alexcrichton/cookie-rs fork |
dev | The |
error | Error and Result module |
guard | Route match guards. |
http | Various HTTP related types |
middleware | Middlewares |
test | Various helpers for Actix applications to use during testing. |
web | Essentials helper functions and types for application registration. |
Structs
App | Application builder - structure that follows the builder pattern for building application instances. |
Error | General purpose actix web error. |
HttpRequest | An HTTP Request |
HttpResponse | An HTTP Response |
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 different responder types into a single type |
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 a http response. |
ResponseError | Error that can be converted to |
Type Definitions
Result | A specialized |