https://github.com/jaemk/mini_http
mini async http server
https://github.com/jaemk/mini_http
asynchronous http http-server mio
Last synced: 6 months ago
JSON representation
mini async http server
- Host: GitHub
- URL: https://github.com/jaemk/mini_http
- Owner: jaemk
- License: mit
- Created: 2017-11-15T04:41:14.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-03T01:41:19.000Z (about 8 years ago)
- Last Synced: 2025-03-23T23:24:13.949Z (11 months ago)
- Topics: asynchronous, http, http-server, mio
- Language: Rust
- Size: 37.1 KB
- Stars: 2
- Watchers: 2
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mini_http
[](https://travis-ci.org/jaemk/mini_http)
**Note:** This project is a work in progress and shouldn't be used in any critical production environment.
> A basic asynchronous* http server using [`mio`](https://docs.rs/mio)
*While network IO is performed asynchronously, handler functions are executed synchronously in a thread pool.
## Usage
See [`examples`](https://github.com/jaemk/mini_http/tree/master/examples)
```rust
extern crate mini_http;
fn run() -> Result<(), Box> {
mini_http::Server::new("127.0.0.1:3000")?
.start(|request| {
println!("{:?}", std::str::from_utf8(request.body()));
let resp = if request.body().len() > 0 {
request.body().to_vec()
} else {
b"hello!".to_vec()
};
mini_http::Response::builder()
.status(200)
.header("X-What-Up", "Nothin")
.body(resp)
.unwrap()
})?;
Ok(())
}
```