actix-web/actix-http/README.md

2.2 KiB

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 actix_http::HttpService;
use actix_server::Server;
use actix_service::map_config;
use actix_web::{dev::AppConfig, get, App};

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    Server::build()
        .bind("hello-world", "127.0.0.1:8080", || {
            // construct actix-web app.
            let app = App::new().service(index);
            HttpService::build()
                // pass the app to service builder.
                // map_config is used to map App's configuration to ServiceBuilder.
                .finish(map_config(app, |_| AppConfig::default()))
                .tcp()
        })?
        .run()
        .await
}

#[get("/")]
async fn index() -> &'static str {
    "Hello,World from actix-web!"
}

License

This project is licensed under either of

at your option.

Code of Conduct

Contribution to the actix-http crate is organized under the terms of the Contributor Covenant, the maintainer of actix-http, @fafhrd91, promises to intervene to uphold that code of conduct.