# Technical Documentation: actix/actix-web

> ℹ️ **Provenance:** Multi-Tier Ingestion · [CodeWiki Reference](https://codewiki.google/github.com/actix/actix-web)

### Overview (`actix-files/README.md`)

# `actix-files`



[](https://crates.io/crates/actix-files)
[](https://docs.rs/actix-files/0.6.9)


<br />
[](https://deps.rs/crate/actix-files/0.6.9)
[](https://crates.io/crates/actix-files)
[](https://discord.gg/NWpN5mmg3x)





Static file serving for Actix Web.

Provides a non-blocking service for serving static files from disk.

## Examples

```rust
use actix_web::App;
use actix_files::Files;

let app = App::new()
    .service(Files::new("/static", ".").prefer_utf8(true));
```



## Sponsors

<a href="https://www.blacksmith.sh/">
  <img src="https://raw.githubusercontent.com/actix/actix-web/main/.github/sponsors/blacksmith.png" alt="CI powered by Blacksmith" width="280" />
</a>

---

### Overview (`actix-http-test/README.md`)

# `actix-http-test`



[](https://crates.io/crates/actix-http-test)
[](https://docs.rs/actix-http-test/3.3.0)


<br>
[](https://deps.rs/crate/actix-http-test/3.3.0)
[](https://crates.io/crates/actix-http-test)
[](https://discord.gg/NWpN5mmg3x)





Various helpers for Actix applications to use during testing.



## Sponsors

<a href="https://www.blacksmith.sh/">
  <img src="https://raw.githubusercontent.com/actix/actix-web/main/.github/sponsors/blacksmith.png" alt="CI powered by Blacksmith" width="280" />
</a>

---

### Overview (`actix-http/README.md`)

# `actix-http`

> HTTP types and services for the Actix ecosystem.



[](https://crates.io/crates/actix-http)
[](https://docs.rs/actix-http/3.19.0)


<br />
[](https://deps.rs/crate/actix-http/3.19.0)
[](https://crates.io/crates/actix-http)
[](https://discord.gg/NWpN5mmg3x)



## Examples

```rust
use std::{env, io};

use actix_http::{HttpService, Response};
use actix_server::Server;
use futures_util::future;
use http::header::HeaderValue;
use tracing::info;

#[actix_rt::main]
async fn main() -> io::Result<()> {
    env::set_var("RUST_LOG", "hello_world=info");
    env_logger::init();

    Server::build()
        .bind("hello-world", "127.0.0.1:8080", || {
            HttpService::build()
                .client_timeout(1000)
                .client_disconnect(1000)
                .finish(|_req| {
                    info!("{:?}", _req);
                    let mut res = Response::Ok();
                    res.header("x-head", HeaderValue::from_static("dummy value!"));
                    future::ok::<_, ()>(res.body("Hello world!"))
                })
                .tcp()
        })?
        .run()
        .await
}
```

## Sponsors

<a href="https://www.blacksmith.sh/">
  <img src="https://raw.githubusercontent.com/actix/actix-web/main/.github/sponsors/blacksmith.png" alt="CI powered by Blacksmith" width="280" />
</a>

---

### Overview (`actix-multipart-derive/README.md`)

# `actix-multipart-derive`

> The derive macro implementation for actix-multipart-derive.



[](https://crates.io/crates/actix-multipart-derive)
[](https://docs.rs/actix-multipart-derive/0.8.1)


<br />
[](https://deps.rs/crate/actix-multipart-derive/0.8.1)
[](https://crates.io/crates/actix-multipart-derive)
[](https://discord.gg/NWpN5mmg3x)



## Sponsors

<a href="https://www.blacksmith.sh/">
  <img src="https://raw.githubusercontent.com/actix/actix-web/main/.github/sponsors/blacksmith.png" alt="CI powered by Blacksmith" width="280" />
</a>

---

### Overview (`actix-multipart/README.md`)

# `actix-multipart`



[](https://crates.io/crates/actix-multipart)
[](https://docs.rs/actix-multipart/0.8.5)


<br />
[](https://deps.rs/crate/actix-multipart/0.8.5)
[](https://crates.io/crates/actix-multipart)
[](https://discord.gg/NWpN5mmg3x)





Multipart request & form support for Actix Web.

The [`Multipart`] extractor aims to support all kinds of `multipart/*` requests, including `multipart/form-data`, `multipart/related` and `multipart/mixed`. This is a lower-level extractor which supports reading [multipart fields](Field), in the order they are sent by the client.

Due to additional requirements for `multipart/form-data` requests, the higher level [`MultipartForm`] extractor and derive macro only supports this media type.

## Examples

```rust
use actix_multipart::form::{
    json::Json as MpJson, tempfile::TempFile, MultipartForm, MultipartFormConfig,
};
use actix_web::{middleware::Logger, post, App, HttpServer, Responder};
use serde::Deserialize;

#[derive(Debug, Deserialize)]
struct Metadata {
    name: String,
}

#[derive(Debug, MultipartForm)]
struct UploadForm {
    // Note: the form is also subject to the global limits configured using `MultipartFormConfig`.
    #[multipart(limit = "100MB")]
    file: TempFile,
    json: MpJson<Metadata>,
}

#[post("/videos")]
async fn post_video(MultipartForm(form): MultipartForm<UploadForm>) -> impl Responder {
    format!(
        "Uploaded file {}, with size: {}\ntemporary file ({}) was deleted\n",
        form.json.name,
        form.file.size,
        form.file.file.path().display(),
    )
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));

    HttpServer::new(move || {
        App::new()
            .service(post_video)
            .wrap(Logger::default())
            // Also increase the global total limit to 100MiB.
            .app_data(MultipartFormConfig::default().total_limit(100 * 1024 * 1024))
    })
    .workers(2)
    .bind(("127.0.0.1", 8080))?
    .run()
    .await
}
```

cURL request:

```sh
curl -v --request POST \
  --url http://localhost:8080/videos \
  -F 'json={"name": "Cargo.lock"};type=application/json' \
  -F file=@./Cargo.lock
```



[More available in the examples repo &rarr;](https://github.com/actix/examples/tree/main/forms/multipart)

## Sponsors

<a href="https://www.blacksmith.sh/">
  <img src="https://raw.githubusercontent.com/actix/actix-web/main/.github/sponsors/blacksmith.png" alt="CI powered by Blacksmith" width="280" />
</a>

[`MultipartForm`]: struct@form::MultipartForm

---

### Overview (`actix-router/README.md`)

# `actix-router`



[](https://crates.io/crates/actix-router)
[](https://docs.rs/actix-router/0.5.3)


<br />
[](https://deps.rs/crate/actix-router/0.5.3)
[](https://crates.io/crates/actix-router)
[](https://discord.gg/NWpN5mmg3x)





Resource path matching and router.



## Sponsors

<a href="https://www.blacksmith.sh/">
  <img src="https://raw.githubusercontent.com/actix/actix-web/main/.github/sponsors/blacksmith.png" alt="CI powered by Blacksmith" width="280" />
</a>

---

### Overview (`actix-test/README.md`)

# `actix-test`



[](https://crates.io/crates/actix-test)
[](https://docs.rs/actix-test/0.1.5)


<br />
[](https://deps.rs/crate/actix-test/0.1.5)
[](https://crates.io/crates/actix-test)
[](https://discord.gg/NWpN5mmg3x)





Integration testing tools for Actix Web applications.

The main integration testing tool is [`TestServer`]. It spawns a real HTTP server on an unused port and provides methods that use a real HTTP client. Therefore, it is much closer to real-world cases than using `init_service`, which skips HTTP encoding and decoding.

## Examples

```rust
use actix_web::{get, web, test, App, HttpResponse, Error, Responder};

#[get("/")]
async fn my_handler() -> Result<impl Responder, Error> {
    Ok(HttpResponse::Ok())
}

#[actix_rt::test]
async fn test_example() {
    let srv = actix_test::start(||
        App::new().service(my_handler)
    );

    let req = srv.get("/");
    let res = req.send().await.unwrap();

    assert!(res.status().is_success());
}
```



## Sponsors

<a href="https://www.blacksmith.sh/">
  <img src="https://raw.githubusercontent.com/actix/actix-web/main/.github/sponsors/blacksmith.png" alt="CI powered by Blacksmith" width="280" />
</a>

---

### Overview (`actix-web-actors/README.md`)

# `actix-web-actors`

> Actix actors support for Actix Web.
>
> This crate is deprecated. Migrate to [`actix-ws`](https://crates.io/crates/actix-ws).



[](https://crates.io/crates/actix-web-actors)
[](https://docs.rs/actix-web-actors/4.3.1)


<br />

[](https://crates.io/crates/actix-web-actors)
[](https://discord.gg/NWpN5mmg3x)



## Sponsors

<a href="https://www.blacksmith.sh/">
  <img src="https://raw.githubusercontent.com/actix/actix-web/main/.github/sponsors/blacksmith.png" alt="CI powered by Blacksmith" width="280" />
</a>

---

### Overview (`actix-web-codegen/README.md`)

# `actix-web-codegen`

> Routing and runtime macros for Actix Web.



[](https://crates.io/crates/actix-web-codegen)
[](https://docs.rs/actix-web-codegen/4.4.0)


<br />
[](https://deps.rs/crate/actix-web-codegen/4.4.0)
[](https://crates.io/crates/actix-web-codegen)
[](https://discord.gg/NWpN5mmg3x)



## Compile Testing

Uses the [`trybuild`] crate. All compile fail tests should include a stderr file generated by `trybuild`. See the [workflow section](https://github.com/dtolnay/trybuild#workflow) of the trybuild docs for info on how to do this.

## Sponsors

<a href="https://www.blacksmith.sh/">
  <img src="https://raw.githubusercontent.com/actix/actix-web/main/.github/sponsors/blacksmith.png" alt="CI powered by Blacksmith" width="280" />
</a>

[`trybuild`]: https://github.com/dtolnay/trybuild

---

### Overview (`actix-web/README.md`)

<div align="center">
  <h1>Actix Web</h1>
  <p>
    <strong>Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust</strong>
  </p>
  <p>



[](https://crates.io/crates/actix-web)
[](https://docs.rs/actix-web/4.17.0)


[](https://deps.rs/crate/actix-web/4.17.0)
<br />
[](https://github.com/actix/actix-web/actions/workflows/ci.yml)
[](https://github.com/actix/actix-web/actions/workflows/coverage.yml)

[](https://discord.gg/NWpN5mmg3x)



  </p>
</div>

## Features

- Supports _HTTP/1.x_ and _HTTP/2_
- Streaming and pipelining
- Powerful [request routing](https://actix.rs/docs/url-dispatch/) with optional macros
- Full [Tokio](https://tokio.rs) compatibility
- Keep-alive and slow requests handling
- Client/server [WebSockets](https://actix.rs/docs/websockets/) support
- Transparent content compression/decompression (br, gzip, deflate, zstd)
- Multipart streams
- Static assets
- SSL support using OpenSSL or Rustls
- Middlewares ([Logger, Session, CORS, etc](https://actix.rs/docs/middleware/))
- Integrates with the [`awc` HTTP client](https://docs.rs/awc/)
- Runs on stable Rust 1.88+

### Experimental features

To enable faster release iterations, we mark some features as experimental. These features are prefixed with `experimental` and a breaking change may happen at any release. Please use them in a production environment at your own risk.

- `experimental-introspection`: exposes route and method reporting helpers for local diagnostics and tooling. See [`examples/introspection.rs`](examples/introspection.rs) and [`examples/introspection_multi_servers.rs`](examples/introspection_multi_servers.rs).

## Documentation

- [Website & User Guide](https://actix.rs)
- [Examples Repository](https://github.com/actix/examples)
- [API Documentation](https://docs.rs/actix-web)
- [API Documentation (main branch)](https://actix.rs/actix-web/actix_web)

## Example

Dependencies:

```toml
[dependencies]
actix-web = "4"
```

Code:

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

#[get("/hello/{name}")]
async fn greet(name: web::Path<String>) -> impl Responder {
    format!("Hello {name}!")
}

#[actix_web::main] // or #[tokio::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
        App::new().service(greet)
    })
    .bind(("127.0.0.1", 8080))?
    .run()
    .await
}
```

### More Examples

- [Hello World](https://github.com/actix/examples/tree/main/basics/hello-world)
- [Basic Setup](https://github.com/actix/examples/tree/main/basics/basics)
- [Application State](https://github.com/actix/examples/tree/main/basics/state)
- [JSON Handling](https://github.com/actix/examples/tree/main/json/json)
- [Multipart Streams](https://github.com/actix/examples/tree/main/forms/multipart)
- [MongoDB Integration](https://github.com/actix/examples/tree/main/databases/mongodb)
- [Diesel Integration](https://github.com/actix/examples/tree/main/databases/diesel)
- [SQLite Integration](https://github.com/actix/examples/tree/main/databases/sqlite)
- [Postgres Integration](https://github.com/actix/examples/tree/main/databases/postgres)
- [Tera Templates](https://github.com/actix/examples/tree/main/templating/tera)
- [Askama Templates](https://github.com/actix/examples/tree/main/templating/askama)
- [HTTPS using Rustls](https://github.com/actix/examples/tree/main/https-tls/rustls)
- [HTTPS using OpenSSL](https://github.com/actix/examples/tree/main/https-tls/openssl)
- [Simple WebSocket](https://github.com/actix/examples/tree/main/websockets)
- [WebSocket Chat](https://github.com/actix/examples/tree/main/websockets/chat)

You may consider checking out [this directory](https://github.com/actix/examples/tree/main) for more examples.

## Benchmarks

One of the fastest web frameworks available according to the [TechEmpower Framework Benchmark](https://www.techempower.com/benchmarks/#section=data-r21&test=composite).

## License

This project is licensed under either of the following licenses, at your option:

- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or [http://www.apache.org/licenses/LICENSE-2.0])
- MIT license ([LICENSE-MIT](LICENSE-MIT) or [http://opensource.org/licenses/MIT])

## Code of Conduct

Contribution to the `actix/actix-web` repo is organized under the terms of the Contributor Covenant. The Actix team promises to intervene to uphold that code of conduct.

## Sponsors

<a href="https://www.blacksmith.sh/">
  <img src="https://raw.githubusercontent.com/actix/actix-web/main/.github/sponsors/blacksmith.png" alt="CI powered by Blacksmith" width="280" />
</a>

---

### Overview (`awc/README.md`)

# `awc` (Actix Web Client)

> Async HTTP and WebSocket client library.



[](https://crates.io/crates/awc)
[](https://docs.rs/awc/3.10.0)

[](https://deps.rs/crate/awc/3.10.0)
[](https://discord.gg/NWpN5mmg3x)



## Examples

[Example project using TLS-enabled client →](https://github.com/actix/examples/tree/main/https-tls/awc-https)

Basic usage:

```rust
use actix_rt::System;
use awc::Client;

fn main() {
    System::new().block_on(async {
        let client = Client::default();

        let res = client
            .get("http://www.rust-lang.org")    // <- Create request builder
            .insert_header(("User-Agent", "Actix-web"))
            .send()                             // <- Send http request
            .await;

        println!("Response: {:?}", res);        // <- server http response
    });
}
```

## Sponsors

<a href="https://www.blacksmith.sh/">
  <img src="https://raw.githubusercontent.com/actix/actix-web/main/.github/sponsors/blacksmith.png" alt="CI powered by Blacksmith" width="280" />
</a>

---

### Overview (`actix-web/examples/README.md`)

# Actix Web Examples

This folder contain just a few standalone code samples. There is a much larger registry of example projects [in the examples repo](https://github.com/actix/examples).

---

### Overview (`docs/graphs/README.md`)

# Actix Ecosystem Dependency Graphs

See rendered versions of these dot graphs [on the wiki](https://github.com/actix/actix-web/wiki/Dependency-Graph).

## Rendering

Dot graphs were rendered using the `dot` command from [GraphViz](https://www.graphviz.org/doc/info/command.html):

```sh
for f in $(ls docs/graphs/*.dot | xargs); do dot $f -Tpng -o${f:r}.png; done
```

---

--- METRICS ---
- Files Extracted: 13
- Estimated Token Budget: ~3876 tokens
- Canonical Reference: https://codewiki.google/github.com/actix/actix-web
