Crate actix_web [] [src]

Actix web is a small, pragmatic, extremely fast, web framework for Rust.

use actix_web::*;

fn index(req: HttpRequest) -> String {
    format!("Hello {}!", &req.match_info()["name"])
}

fn main() {
    HttpServer::new(
        || Application::new()
            .resource("/{name}", |r| r.f(index)))
        .bind("127.0.0.1:8080").unwrap()
        .run();
}

Documentation

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
  • Graceful server shutdown
  • Multipart streams
  • SSL support with openssl or native-tls
  • Middlewares (Logger, Session, CORS, DefaultHeaders)
  • Built on top of Actix actor framework.

Reexports

pub use error::Error;
pub use error::Result;
pub use error::ResponseError;

Modules

client

Http client

dev

The actix-web prelude for library developers

error

Error and Result module

fs

Static files support.

headers

Headers implementation

httpcodes

Basic http responses

middleware

Middlewares

multipart

Multipart requests support

pred

Route match predicates

server

Http server

test

Various helpers for Actix applications to use during testing.

ws

WebSocket support for Actix

Structs

Application

Structure that follows the builder pattern for building Application structs.

HttpContext

Http actor execution context

HttpRequest

An HTTP Request

HttpResponse

An HTTP Response

HttpServer

An HTTP Server

Json

Json response helper

Method

The Request Method (VERB)

NormalizePath

Path normalization helper

Reply

Represents response process.

Resource

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

Route

Resource route definition

StatusCode

An HTTP status code (status-code in RFC 7230 et al.).

Version

Represents a version of the HTTP spec.

Enums

Binary

Represents various types of binary body. Content-Length header is set to length of the body.

Body

Represents various types of http message body.

Traits

HttpMessage

Trait that implements general purpose operations on http messages

Responder

Trait implemented by types that generate responses for clients.