logo

Crate actix_web[][src]

Expand description

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.

Example

use actix_web::{get, web, App, HttpServer, Responder};

#[get("/{id}/{name}/index.html")]
async fn index(web::Path((id, name)): web::Path<(u32, String)>) -> impl Responder {
    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 and HttpResponse: These structs represent HTTP requests and responses and expose methods for creating, inspecting, and otherwise utilizing them.

Features

Crate Features

  • compress - content encoding compression support (enabled by default)
  • openssl - HTTPS support via openssl crate, supports HTTP/2
  • rustls - HTTPS support via rustls crate, supports HTTP/2
  • secure-cookies - secure cookies support

Re-exports

pub use actix_http::cookie;
pub use actix_rt as rt;

Modules

Actix web async HTTP client.

The actix-web prelude for library developers

Error and Result module

Route match guards.

Various HTTP related types

Middlewares

Various helpers for Actix applications to use during testing.

Essentials helper functions and types for application registration.

Structs

Application builder - structure that follows the builder pattern for building application instances.

General purpose actix web error.

An HTTP Request

An HTTP Response

An HTTP Server.

Resource is an entry in resources table which corresponds to requested URL.

Resource route definition

Resources scope.

Enums

Combines two different responder types into a single type

A composite error resulting from failure to extract an Either<A, B>.

Traits

Trait implemented by types that can be extracted from request.

Trait that implements general purpose operations on http messages

Trait implemented by types that can be converted to a http response.

Error that can be converted to Response

Type Definitions

A specialized Result for actix web operations

Attribute Macros

Creates route handler with actix_web::guard::Connect.

Creates route handler with actix_web::guard::Delete.

Creates route handler with actix_web::guard::Get.

Creates route handler with actix_web::guard::Head.

Marks async main function as the actix system entry-point.

Creates route handler with actix_web::guard::Options.

Creates route handler with actix_web::guard::Patch.

Creates route handler with actix_web::guard::Post.

Creates route handler with actix_web::guard::Put.

Creates resource handler, allowing multiple HTTP method guards.

Creates route handler with actix_web::guard::Trace.