hunter / hayaku

Microframework inspired by Golang's net/http

commit 5f0d211a3265ca35f89a5819714b841dd8eca696

author Hunter Praska

time 2018-05-17 20:14:56 -05:00

Fix bug with forms

Forgot the else block here

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