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

#152 in Web programming

Download history 180621/week @ 2024-01-22 170927/week @ 2024-01-29 176236/week @ 2024-02-05 180469/week @ 2024-02-12 174411/week @ 2024-02-19 196159/week @ 2024-02-26 199929/week @ 2024-03-04 190881/week @ 2024-03-11 191131/week @ 2024-03-18 189695/week @ 2024-03-25 209483/week @ 2024-04-01 196906/week @ 2024-04-08 209126/week @ 2024-04-15 222594/week @ 2024-04-22 214184/week @ 2024-04-29 200880/week @ 2024-05-06

855,903 downloads per month
Used in 1,068 crates (149 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–25MB
~423K SLoC