http-serve

Rust helpers for serving HTTP GET and HEAD responses with hyper 0.13.x and tokio.

This crate supplies two ways to respond to HTTP GET and HEAD requests:

Why two ways?

They have pros and cons. This chart shows some of them:

servestreaming_body
automatic byte range servingyesno (always sends full body)
backpressureyesno
conditional GETyesunimplemented (always sends body)
sends first byte before length knownnoyes
automatic gzip content encodingnoyes

There's also a built-in Entity implementation, ChunkedReadFile. It serves static files from the local filesystem, reading chunks in a separate thread pool to avoid blocking the tokio reactor thread.

You're not limited to the built-in entity type(s), though. You could supply your own that do anything you desire:

http_serve::serve is similar to golang's http.ServeContent. It was extracted from moonfire-nvr's .mp4 file serving.

Try the example:

$ cargo run --example serve_file /usr/share/dict/words

Authors

See the AUTHORS file for details.

License

Your choice of MIT or Apache; see LICENSE-MIT.txt or LICENSE-APACHE, respectively.