hunter / hayaku

Microframework inspired by Golang's net/http

Clone this repo

Branches
View All
  • f014bc0 Update dependencies by Hunter Praska at 2019-01-20 23:53:58 -06:00

  • f9699de Default to num_cpus event loops by Hunter Praska at 2018-08-04 17:10:53 -05:00

  • 5f0d211 Fix bug with forms by Hunter Praska at 2018-05-17 20:14:56 -05:00

  • 13d7f8b Change unreachable to panic by Hunter Praska at 2018-02-10 00:46:43 -06:00

  • 1275eef Update dependencies by Hunter Praska at 2018-01-20 01:54:20 -06:00

View Log

hayaku

An http library inspired by Golang's net/http.

Various example servers are included in examples/. For a more complex use case, take a look at neppit.

Using

Place hayaku = { git="https://git.hunterpraska.com/hayaku/hayaku" } in your Cargo.toml.

extern crate hayaku;

use hayaku::{Http, Router, Request, Response};

use std::sync::Arc;

fn main() {
    let addr = "127.0.0.1:3000".parse().unwrap();
    let mut router = Router::new();
    router.get("/", Arc::new(home_handler)).unwrap();

    Http::new(router, ()).listen_and_serve(addr);
}

fn home_handler(_req: &mut Request, res: Response, _ctx: &()) -> Result<(), ()> {
    res.body(b"Hello, world!");
    Ok(())
}

TODO

  • Testing library for applications (Hard)
  • Handle form parsing for multipart data (Hard)
  • Documentation (Hard)
  • TLS support (Hard)
  • Requests to other servers (Hard)
    • This will probably wait for the 1.0 sync http lib