NOTE: This library was renamed to Servlin.
Beatrice
A modular HTTP server library in Rust.
Features
forbid(unsafe_code)- Threaded request handlers:
FnOnce(Request) -> Response + 'static + Clone + Send + Sync - Uses async code internally for excellent performance under load
- JSON
- Server-Sent Events (SSE)
- Saves large request bodies to temp files
- Sends 100-Continue
- Limits number of threads and connections
- Modular: roll your own logging, write custom versions of internal methods, etc.
- No macros or complicated type params
- Good test coverage (63%)
Limitations
- New, not proven in production.
- To do:
- Request timeouts
chunkedtransfer-encoding for request bodies- gzip
- brotli
- TLS
- automatically getting TLS certs via ACME
- Drop idle connections when approaching connection limit.
- Denial-of-Service mitigation: source throttling, minimum throughput
- Complete functional test suite
- Missing load tests
- Disk space usage limits
Examples
Complete examples: examples/.
Simple example:
use ;
use ;
use Deserialize;
use json;
use Arc;
use TempDir;
let state = new;
let request_handler = move |req: Request| ;
let cache_dir = new.unwrap;
start_timer_thread;
let executor = new.unwrap;
# let permit = new;
# let server_permit = permit.new_sub;
# spawn;
executor.block_on.unwrap;
Cargo Geiger Safety Report
Alternatives
See rust-webserver-comparison.md.
Changelog
- v0.3.2 - Renaming project to 'servlin'.
- v0.3.1 - Add
Response::include_dir. - v0.3.0
- Add
RequestBody::StaticBytes. - Add
ResponseBody::StaticBytes. - Remove
impl From<&[u8]>forRequestBodyandResponseBody.
- Add
- v0.2.0 - Make
print_log_responseeasier to use. - v0.1.0 - First published version
TO DO
- Fix limitations above
- Support HEAD responses that have Content-Length set and no body.
- Update
rust-webserver-comparison.md- Add missing data
- Add other servers from https://www.arewewebyet.org/topics/frameworks/
- Rearrange
- Generate geiger reports for each web server