Sailboat

The problem

The rust http server framework genre seems to be filled with a large overuse of macros to produce framework structures that are essentially a sub-language of rust.

The solution

Sailboat is focused on simplicity while still maintaining speed. This library avoids complex, unclear, or otherwise unnecessary macros preferring instead to write (at times) more verbose yet clear; clean code.

Checklist

Order of tasks not necessarily in order of completion

Example

Run examples using cargo run --example example_name

A basic hello world program using sailboat:

```rust use sailboat::{Service, Application, System, Request, Response, StatusCode};

fn helloworld(req: &Request) -> Option { // Responding with None will act as a middleware System // Responding with Some will respond to the request object and move on to the next request // All systems registered after receiving a Some will not be run

Some(Response::empty(StatusCode(200)))

}

fn main() -> Result<(), Box> { let root = Service::root() .fold(|s| { s.insertchild(Service::withsystem("helloworld", System::single(helloworld))) });

// The application will automatically respond to all unrecognized urls with a `StatusCode(404)` not found
// In this case, the only recognized url is `localhost/hello_world`
let app = Application::new("0.0.0.0:80", root)?;

// Initiate main application loop
let _ = app.run();

Ok(())

} ```

Performance

On my personal computer using wrk -t 4 -c 4 A basic hello_world example revealed the following

sailboat: ~240k req/sec actix: ~280k req/sec tiny_http: ~280k req/sec rouille: ~80k req/sec

Documentation

This crate aims to be 100% fully documented.

Licensing

See LICENSE-MIT