| Crates.io | voidy |
| lib.rs | voidy |
| version | 0.2.0 |
| created_at | 2022-01-14 11:29:17.316245+00 |
| updated_at | 2022-01-19 01:30:09.812747+00 |
| description | A library to handle HTTP/2 requests asynchronously. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 513817 |
| size | 24,306 |
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(())
}