7 unstable releases (3 breaking)

0.4.1 Mar 31, 2024
0.4.0 Mar 4, 2024
0.3.0 Feb 16, 2024
0.2.2 Feb 2, 2024
0.1.0 Dec 29, 2023

#251 in HTTP client

Download history 74/week @ 2023-12-31 18/week @ 2024-01-07 124/week @ 2024-01-14 46/week @ 2024-01-21 27/week @ 2024-01-28 206/week @ 2024-02-04 393/week @ 2024-02-11 82/week @ 2024-02-18 109/week @ 2024-02-25 259/week @ 2024-03-03 70/week @ 2024-03-10 23/week @ 2024-03-17 63/week @ 2024-03-24 409/week @ 2024-03-31 51/week @ 2024-04-07 19/week @ 2024-04-14

546 downloads per month
Used in 2 crates (via xitca-web)

Apache-2.0

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

~1–16MB
~192K SLoC