front-line
A declarative, zero-copy HTTP router for Rust.
The front-line crate offers utilities to route HTTP requests based on their
method and path. With declarative macro-driven approach, it's suitable for
both complex and straightforward use cases.
Features:
- Declarative: With the help of proc-macro attributes, you can easily define routes as enums.
- Zero-copy capture: Dynamic segments from paths, such as
/users/{id}, can be captured without unnecessary data copying, ensuring efficient memory usage. - Dispatch free: The crate focuses purely on route resolution based on the path, leaving dispatch methods up to the user's discretion.
Basic Usage:
use FrontLine;
use ;
// Construct an example http request, typically read from a socket.
let request = b"GET /api/users/42?a=b HTTP/1.1\r\n\r\nContent-Length: 12\r\n\r\nHello World!";
// Parse and resolve the route
let route = resolve;
// For demonstration purposes, assert the resolved route matches expectations
assert!;