79 releases (19 stable)

3.4.0 Aug 29, 2023
3.3.1 Mar 2, 2023
3.3.0 Jan 21, 2023
3.2.2 Sep 11, 2022
0.1.0-alpha.2 Mar 30, 2019

#39 in Web programming

Download history 141519/week @ 2023-08-16 143792/week @ 2023-08-23 140343/week @ 2023-08-30 157812/week @ 2023-09-06 152901/week @ 2023-09-13 143749/week @ 2023-09-20 153516/week @ 2023-09-27 168810/week @ 2023-10-04 172454/week @ 2023-10-11 169479/week @ 2023-10-18 169635/week @ 2023-10-25 175246/week @ 2023-11-01 164616/week @ 2023-11-08 175378/week @ 2023-11-15 151381/week @ 2023-11-22 145363/week @ 2023-11-29

668,790 downloads per month
Used in 964 crates (142 directly)

MIT/Apache

600KB
14K SLoC

actix-http

HTTP primitives for the Actix ecosystem.

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

Documentation & Resources

Example

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

~9–24MB
~420K SLoC