86 releases (26 stable)

3.11.0 May 10, 2025
3.10.0 Mar 10, 2025
3.9.0 Aug 10, 2024
3.8.0 Jun 19, 2024
0.1.0-alpha.2 Mar 30, 2019

#11 in #actix

Download history 368996/week @ 2025-02-01 375871/week @ 2025-02-08 343005/week @ 2025-02-15 417554/week @ 2025-02-22 403949/week @ 2025-03-01 432874/week @ 2025-03-08 435398/week @ 2025-03-15 441622/week @ 2025-03-22 403315/week @ 2025-03-29 430540/week @ 2025-04-05 405830/week @ 2025-04-12 403287/week @ 2025-04-19 352039/week @ 2025-04-26 360849/week @ 2025-05-03 411986/week @ 2025-05-10 362595/week @ 2025-05-17

1,554,229 downloads per month
Used in 1,385 crates (170 directly)

MIT/Apache

620KB
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

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

~8–22MB
~419K SLoC