Expand description
§🪶 Feather: Synchronous DX-First Minimal Web Framework for Rust
Feather is a lightweight, middleware-first web framework for Rust, inspired by Express.js but designed for Rust’s performance and safety. Build fast, synchronous web applications without async complexity.
§Quick Start
Add to Cargo.toml:
[dependencies]
feather = "0.6"Hello world in 5 lines:
ⓘ
use feather::{App, middleware, next};
let mut app = App::new();
app.get("/", middleware!(|_req, res, _ctx| {
res.send_text("Hello, Feather!");
next!()
}));
app.listen("127.0.0.1:5050");§Why Feather?
- Fully Synchronous: No async/await complexity. Built on lightweight coroutines for excellent performance.
- Express.js Inspired: Familiar API with
app.get(),app.post(), middleware chains. - DX First: Minimal boilerplate, clear APIs, easy to learn and use.
- Built-in Features: Routing, middleware, state management, error handling, JWT auth.
- Multithreaded by Default: Powered by Feather-Runtime for high concurrency.
§Comprehensive Guides
Feather comes with detailed guides for every aspect:
- Getting Started - Setup and core concepts
- Routing - HTTP methods, paths, and handlers
- Middlewares - Request processing pipelines
- State Management - Application context and data sharing
- Error Handling - Error patterns and recovery
- Authentication - JWT tokens and protected routes
- Server Configuration - Tuning and optimization
§Common Tasks
Add a route:
ⓘ
app.get("/users/:id", middleware!(|req, res, ctx| {
// Handle request
res.send_text("User details");
next!()
}));Use middleware:
ⓘ
app.use_middleware(middleware!(|req, res, _ctx| {
println!("{} {}", req.method, req.uri);
next!()
}));Manage state:
ⓘ
use feather::State;
app.context().set_state(State::new(MyConfig { /* ... */ }));
// Later in middleware:
let config = ctx.get_state::<State<MyConfig>>();§Next Steps
Start with the Getting Started Guide for a comprehensive introduction, or jump to any specific guide above for deep dives into features you need.
§Missing Feature?
Don’t see something you need? Check out the GitHub repository for issues, feature requests, and contribution guidelines. Don’t hesitate to open an issue or submit a pull request!
Re-exports§
pub use crate::middlewares::MiddlewareResult;pub use internals::App;pub use internals::AppContext;pub use crate::internals::State;
Modules§
- guides
- Comprehensive guides and tutorials for Feather.
- internals
- Internal implementation details of the Feather framework.
- middlewares
- Middleware system for request processing.
- prelude
Macros§
- chain
- A macro to chain multiple middlewares together.
This macro takes a list of middlewares and chains them together. - info
- Logs a message at the info level.
- middleware
- The
middleware!macro allows you to define middleware functions concisely without repeating type signatures. - next
- This macro is just a syntactic sugar over the
Ok(MiddlewareResult::Next)syntax just to clear some Boilerplate - trace
- Logs a message at the trace level.
- warn
- Logs a message at the warn level.
Structs§
- Request
- Contains a incoming Http Request
- Response
- Server
Config - Configuration for the HTTP server
Type Aliases§
- Outcome
- This is just a type alias for
Result<MiddlewareResult, Box<dyn Error>>;
Outcome is used in All middlewares as a return type.
Attribute Macros§
- middleware_
fn - Attribute macro for defining middleware functions with automatic signature injection.