Crates.io | zap |
lib.rs | zap |
version | 0.0.4 |
source | src |
created_at | 2017-10-02 15:18:21.04488 |
updated_at | 2017-11-13 16:24:35.819674 |
description | Ligthing fast web framework for rust |
homepage | |
repository | https://github.com/oldaniel/zap |
max_upload_size | |
id | 34179 |
size | 13,182 |
zap
:zap:The mission of zap
is, to deliver a basic, but fast rust web framework.
This code is based on tokio's minihttp project, so a big thanks to them. (source)
Add the following to your Cargo.toml
:
[dependencies]
zap = "0.0.4"
So zap
is not only fast, it is wapping 2.96 times faster than iron, which is based on hyper. Benchmarks below:
Iron
This code had been taken from the ironframework.io webpage.
extern crate iron;
use iron::prelude::*;
use iron::status;
fn main() {
fn hello_world(_: &mut Request) -> IronResult<Response> {
Ok(Response::with((status::Ok, "Hello World!")))
}
Iron::new(hello_world).http("localhost:3000").unwrap();
}
Zap
This example can be run, by:
$ git clone https://github.com/oldaniel/zap && cd zap
$ cargo run --example hello-world --release
extern crate zap;
use std::io::Error as ZapError;
use zap::prelude::*;
struct HelloWorld;
impl Handler for HelloWorld {
type Request = Request;
type Response = Response;
type Error = ZapError;
type Future = ZapResult;
fn call(&self, _: Request) -> ZapResult {
let mut resp = Response::new();
resp.body("Hello World!");
resp.ok()
}
}
fn main() {
let addr = "0.0.0.0:8080".parse().unwrap();
let mut server = Server::new(Http, addr);
server.threads(8);
server.serve(|| Ok(HelloWorld));
}
The benchmark results have been computed with this command: wrk -t16 -c500 -d10s http://127.0.0.1:8080 --latency
Technical details about the server:
Detailed results: in the wiki.
Iron
[...]
Requests/sec: 307581.17
Transfer/sec: 33.44MB
Zap
[...]
Requests/sec: 912832.31
Transfer/sec: 40.90MB
Some things we still need to make:
A project by Daniel Oltmanns. Other amazing contributors here.