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.
Production Readiness / Stability
Not yet recommended for production use. Not guaranteed to ever be ready.
Example
Cargo.toml:
= { = "0.14", = ["full"] }
= "0.0"
= "0.1.0-alpha.0"
= "1.4"
= { = "1.0", = ["full"] }
main.rs:
use HashMap;
use SocketAddr;
use ;
use macro_rules_attribute;
use ;
use ;
use Regex;
async
pub async
Features
- Three ways to route requests to handlers
- Static Paths
- Regex Paths - captured patterns are passed to the handler
- Custom Router Function - for example, check a database for dynamic paths
- Automatic HTTP 404 responses when paths are not found, and HTTP 415 when methods are not supported
- Post-Routing / Pre-Request Middleware
- You provide a default list of Middleware to run for all requests
- Override the default Middleware for individual routes
- App defined "Bundle" can be modified by Middleware and is passed to all requests. Example properties:
- Database Connection Pools
- Validated Authentication / Authorization Details
- Parsed Request Bodies
Future Enhancements
- Documentation, examples, documentation... documentation
- Catch unwinding panics and respond with HTTP 500
- Make built-in error responses customizable
- Replace the built in ways to route with implementations of a Router trait
- Replace or re-export http/hyper types, etc.
- Macros for easier to read handler configuration