81 releases (21 stable)

3.6.0 Feb 4, 2024
3.5.1 Dec 25, 2023
3.4.0 Aug 29, 2023
3.3.1 Mar 2, 2023
0.1.0-alpha.2 Mar 30, 2019

#1 in #http-framework

Download history 166787/week @ 2024-01-26 170926/week @ 2024-02-02 185027/week @ 2024-02-09 173511/week @ 2024-02-16 194371/week @ 2024-02-23 198991/week @ 2024-03-01 191067/week @ 2024-03-08 193233/week @ 2024-03-15 190258/week @ 2024-03-22 205929/week @ 2024-03-29 196567/week @ 2024-04-05 206705/week @ 2024-04-12 218066/week @ 2024-04-19 215982/week @ 2024-04-26 206355/week @ 2024-05-03 179609/week @ 2024-05-10

859,874 downloads per month
Used in 1,065 crates (144 directly)

MIT/Apache

605KB
15K SLoC

actix-http

HTTP types and services for the Actix ecosystem.

crates.io Documentation Version MIT or Apache 2.0 licensed
dependency status Download Chat on Discord

Documentation & Resources

Examples

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
}

Dependencies

~10–22MB
~412K SLoC