mini_http

Crates.iomini_http
lib.rsmini_http
version0.0.3
sourcesrc
created_at2017-11-21 03:42:13.984646
updated_at2017-11-28 05:08:34.930502
descriptionSimple HTTP server built on mio
homepage
repository
max_upload_size
id40093
size35,550
James Kominick (jaemk)

documentation

https://docs.rs/mini_http

README

mini_http

Build Status

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

*While network IO is performed asynchronously, handler functions are executed synchronously in a thread pool.

Usage

See examples

extern crate mini_http;

fn run() -> Result<(), Box<std::error::Error>> {
    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(())
}
Commit count: 0

cargo fmt