Marla - Async Web Server Framework for Rust

Marla is a handler and middleware based web server framework for Rust.

Handlers can be called based on static path maps, regex based paths, and fully custom router functions.

Middleware can be configured to run for all requests by default and overridden for specific routes.

Example

You can run this example in examples/hello and browse to http://localhost:3000/hello/world , or use curl:

bash curl -sS http://localhost:3000/hello/world -D-

Cargo.toml: toml [dependencies] hyper = { version = "0.14", features = ["full"] } macro_rules_attribute = "0.0" marla = "0.1.0-alpha.1" regex = "1.4" tokio = { version = "1.0", features = ["full"] }

main.rs: ```rust use std::net::SocketAddr;

use hyper::{Body, Method, Response}; use macrorulesattribute::macrorulesattribute; use marla::{Request, serve, async_handler}; use marla::config::{MarlaConfig, RegexPath, Route}; use regex::Regex;

[tokio::main]

async fn main() { let marlaconfig = MarlaConfig { routers: vec![Box::new(vec![ RegexPath{ regex: Regex::new("^/hello/([a-zA-Z]{1,30})$").unwrap(), routes: vec![ (Method::GET, Route { handler: hello, middleware: None }), ].intoiter().collect()}, ])],

    middleware: vec![],
    listen_addr: SocketAddr::from(([127, 0, 0, 1], 3000)),
};

serve(marla_config, ()).await;

}

[macrorulesattribute(async_handler!)]

pub async fn hello( request: Request, body: Option, _bundle: (), ) -> Response { Response::new(Body::from(format!("Hello, {}\n", request.pathparams[0]))) } ```

Features

Future Enhancements