# Crate actix_web[−][src]

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

    use actix_web::{server, App, Path, Responder};

    fn index(info: Path<(String, u32)>) -> impl Responder {
        format!("Hello {}! id:{}", info.0, info.1)
    }

    fn main() {
        server::new(|| {
            App::new().resource("/{name}/{id}/index.html", |r| r.with(index))
        }).bind("127.0.0.1:8080")
            .unwrap()
            .run();
    }

## Documentation & community resources

Besides the API documentation (which you are currently looking at!), several other resources are available:

- User Guide
- Chat on gitter
- GitHub repository
- Cargo package

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.

- 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
- Graceful server shutdown
- Multipart streams
- SSL support with OpenSSL or `native-tls`
- Middlewares (`Logger`, `Session`, `CORS`, `CSRF`, `DefaultHeaders`)
- Built on top of Actix actor framework
- Supported Rust version: 1.26 or later

## Package feature

- `tls` - enables ssl support via `native-tls` crate
- `alpn` - enables ssl support via `openssl` crate, require for `http/2` support
- `session` - enables session support, includes `ring` crate as dependency
- `brotli` - enables `brotli` compression support, requires `c` compiler
- `flate-c` - enables `gzip`, `deflate` compression support, requires `c` compiler
- `flate-rust` - experimental rust based implementation for `gzip`, `deflate` compression.

## Re-exports

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

## Modules

actix | Re-exports actix's prelude
client | Http client api
dev | The `actix-web` prelude for library developers
error | Error and Result module
fs | Static files support
http | Various HTTP related types
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

## Macros

header |

## Structs

App | Structure that follows the builder pattern for building application instances.
Extensions | A type map of request extensions.
Form | Extract typed information from the request's body.
HttpContext | Execution context for http actors
HttpRequest | An HTTP Request
HttpResponse | An HTTP Response
Json | Json helper
Path | Extract typed information from the request's path.
Query | Extract typed information from from the request's query.
Request | Request's context
Scope | Resources scope
State | Access an application state

## 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.
Either | Combines two different responder types into a single type

## Traits

AsyncResponder | Convenience trait that converts `Future` object to a `Boxed` future
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 generate responses for clients.

## Type Definitions

FutureResponse | Convenience type alias

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)