#http #async #requests #request #response #server #status-code

yanked voidy

A library to handle HTTP/2 requests asynchronously

0.2.0 Jan 19, 2022
0.1.0 Jan 14, 2022

#28 in #status-code

26 downloads per month

MIT license

25KB
516 lines

Voidy

A library to handle HTTP/2 requests asynchronously.

Status:

  • In development
use voidy::{
    Server,
    Result,
    http::{Request, Response, StatusCode},
};

#[async_std::main]
async fn main() -> Result {
    let server = Server::bind("localhost:8000").await?;

    server
        .handle(|mut req: Request| async move {
            if req.path() == "/ok" {
                let response = Response::from(StatusCode::Ok);
                req.respond(response).await?;
            } else {
                let response = Response::from(StatusCode::NotFound);
                req.respond(response).await?;
            }
        })
        .await?;

    Ok(())
}

lib.rs:

Voidy

A library to handle HTTP/2 requests asynchronously.

Dependencies

~5–16MB
~191K SLoC