Crate haro

source ·
Expand description

Haro

Haro is a simple and synchronous web framework written in and for Rust.

Features

  • URL Routing with function/closure/trait type
  • Request & Response with minimal boilerplate
    • Query args
    • Post data
    • JSON
    • Cookie
  • Middleware
  • Template (optional)
  • Database (optional)
  • Tests

Example

The “Hello, World!” of Haro is:

use haro::{Application,  Request, Response};

fn main() {
    let mut app = Application::new("0:8000");
    app.route("/", hello);
    app.run();
}

fn hello(_: Request) -> Response {
    Response::str("Hello Haro")
}

Optional Features

Haro uses a set of feature flags to reduce the amount of compiled code and optional dependencies.

You can also use the full feature flag which will enable all public APIs. Beware that this will pull in many extra dependencies that you may not need.

The following optional features are available:

  • database: Enables Database support.
  • template: Enables Template support.

Examples

The Haro repo contains a number of examples that show how to put all the pieces together.

Modules

Middleware definition and built-in middlewares

Structs

A web Application with routes and middlewares
HTTP Request
HTTP Response

Traits

Functions

redirect is a helper function to generate 301 or 302 Response

Type Definitions

Arc of trait object for route Handler type