10 releases (6 breaking)

Uses new Rust 2024

new 0.7.1 Mar 18, 2025
0.6.0 Jul 24, 2024
0.4.1 Mar 31, 2024
0.1.0 Dec 29, 2023

#483 in HTTP server

Download history 20/week @ 2024-11-27 53/week @ 2024-12-04 81/week @ 2024-12-11 76/week @ 2024-12-18 17/week @ 2024-12-25 41/week @ 2025-01-01 81/week @ 2025-01-08 45/week @ 2025-01-15 34/week @ 2025-01-22 401/week @ 2025-01-29 252/week @ 2025-02-05 296/week @ 2025-02-12 287/week @ 2025-02-19 280/week @ 2025-02-26 142/week @ 2025-03-05 489/week @ 2025-03-12

1,225 downloads per month
Used in 3 crates (2 directly)

Apache-2.0

725KB
20K SLoC

http library for xitca


lib.rs:

Http module for Service trait oriented http handling.

This crate tries to serve both low overhead and ease of use purpose. All http protocols can be used separately with corresponding feature flag or work together for handling different protocols in one place.

Examples

use std::convert::Infallible;

use xitca_http::{
    http::{IntoResponse, Request, RequestExt, Response},
    HttpServiceBuilder,
    RequestBody,
    ResponseBody
};
use xitca_service::{fn_service, Service, ServiceExt};

// xitca-http has to run inside a tcp/udp server.
xitca_server::Builder::new()
    // create http service with given name, socket address and service logic.
    .bind("xitca-http", "localhost:0",
        // a simple async function service produce hello world string as http response.
        fn_service(|req: Request<RequestExt<RequestBody>>| async {
            Ok::<Response<ResponseBody>, Infallible>(req.into_response("Hello,World!"))
        })
        // http service builder is a middleware take control of above function service
        // and bridge tcp/udp transport with the http service.
        .enclosed(HttpServiceBuilder::new())
    )?
    .build()

Dependencies

~0.9–14MB
~208K SLoC