0.2.0 |
|
---|---|
0.1.0 |
|
#196 in #request-response
25KB
516 行
Voidy
一个用于异步处理HTTP/2请求的库。
状态
- 开发中
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
一个用于异步处理HTTP/2请求的库。
依赖
~4–14MB
~164K SLoC