feather 0.3.1

Feather: A minimal HTTP framework for Rust
Documentation

πŸͺΆ Feather

Feather is a lightweight, DX-first web framework for Rust β€” inspired by the simplicity of Express.js, but designed for Rust’s performance and safety.

🧠 No async.
🧱 Middleware-first.
⚑ Just works.


✨ Why Feather?

  • 🧱 Middleware-First Architecture
    Everything is a middleware β€” route handlers, auth, logging, error handling β€” all composable and clean.

  • πŸͺΆ Lightweight and Fast
    Feather uses traditional threads instead of async, avoiding the overhead and complexity of Rust’s async model.

  • 🏦 Easy State Management Using Context
    In the recent version Feather implemented the Context API that allows it have easy state managment without the use of Extractors/Macros

  • πŸ§‘β€πŸ’» Developer Experience First
    Feather’s API is minimal, ergonomic, and readable β€” no lifetimes, no .await,

  • πŸ“¦ Modular and Extensible
    Build the framework you want with plug-and-play middleware, simple traits, and clear primitives.

  • πŸ”¨ Great Tooling Out Of the Box
    With the use of the Feather-CLI Creating API's and Web Servers Become a Breeze.


πŸš€ Getting Started

Add Feather to your Cargo.toml:

[dependencies]
feather = "0.3.1"

🧭 Quick Example

use feather::{App, AppContext, MiddlewareResult,Request, Response};

fn main() {
    let mut app = App::new();
    app.get("/",|_req: &mut Request, res: &mut Response, _ctx: &mut AppContext| {
            res.send_text("Hello, world!");
            MiddlewareResult::Next
    });

    app.listen("127.0.0.1:3000");
}

βœ”οΈ That’s all β€” no async, no magic.


πŸ”Œ Middleware in Feather

Middleware is the heart of Feather. Write it as a closure, a struct, or chain them together:

use feather::{App, AppContext, Request, Response};
use feather::middleware::builtins;
use feather::middleware::{Middleware, MiddlewareResult};
// Implementors of the Middleware trait are middleware that can be used in a Feather app.
struct Custom;
impl Middleware for Custom {
    fn handle(&self,request: &mut Request,_response: &mut Response,_ctx: &mut AppContex) -> MiddlewareResult {
      println!("Now running some custom middleware (struct Custom)!");
      println!("And there's a request with path: {:?}", request.uri);
      MiddlewareResult::Next
    }
}

fn main() {
    let mut app = App::new();
    app.use_middleware(builtins::Logger);
    app.use_middleware(Custom);
    app.use_middleware(|_req: &mut Request, _res: &mut Response, _ctx: &mut AppContext| {
        println!("Now running some custom middleware (closure)!");
        MiddlewareResult::Next
    });

    app.get("/",|_req: &mut Request, res: &mut Response, _ctx: &mut AppContext| {
        res.send_text("Hello, world!");
        MiddlewareResult::Next
    });

    app.listen("127.0.0.1:3000");
}

🏦 State Management using the Context API

Feather's new Context API allows you to manage application-wide state without extractors or macros. Here's an example:

use feather::{App, AppContext, MiddlewareResult, Response, Request};

struct Counter {
    pub count: i32,
}

fn main() {
    let mut app = App::new();
    let counter = Counter { count: 0 };
    app.context().set_state(counter);

    app.get("/", move |_req: &mut Request, res: &mut Response, ctx: &mut AppContext| {
        let counter: &mut Counter = ctx.get_mut_state::<Counter>().unwrap();
        counter.count += 1;
        res.send_text(format!("Counted! {}", counter.count));
        MiddlewareResult::Next
    });
    app.get("/count", move |_req: &mut Request, res: &mut Response, ctx: &mut AppContext| {
        let counter = ctx.get_state::<Counter>().unwrap();
        res.send_text(counter.count.to_string());
        MiddlewareResult::Next
    });

    app.listen("127.0.0.1:5050");
}

Context Is more useful when combined with Database/File Accesses

πŸ” Built-in JWT Authentication

Feather has native JWT middleware activated using a cargo feature jwt:

[dependencies]
feather = { version = "0.3.1", features = ["jwt"] }
use feather::jwt::{generate_jwt, with_jwt_auth};
use feather::{App, AppContext};

fn main() {
    let mut app = App::new();
    app.get("/auth",with_jwt_auth("secretcode", |_req, res,_ctx, claim| {
        println!("Claim: {:?}", claim);
        res.send_text("Hello, JWT!");
        feather::MiddlewareResult::Next
      }),
    );
    // Check the JWT Example for more complete version!
    app.listen("127.0.0.1:8080")
}

No need to reach out for 3rd Party Crates Feather Got you Covered!

🧱 Goals

  • πŸͺΆ Be the simplest Rust web framework to get started with
  • 🧩 Be modular and easy to extend
  • πŸ’‘ Focus on DX without sacrificing Rust's safety and performance

🀝 Contributing

PRs welcome!
If you’ve got ideas or bugs, open an issue or submit a pull request.

# Getting started with dev
git clone https://github.com/BersisSe/feather.git
cd feather
cargo run --example app

πŸ“„ License

Feather is MIT licensed. See LICENSE.


πŸ™ Acknowledgments

Feather is inspired by Express.js and exists to bring that same productivity to Rust.

Thanks to the Rust community for the incredible ecosystem this project builds on.


πŸ“£ Spread the Word

If you like Feather:

  • ⭐ Star it on GitHub
  • πŸ“° Share it on Reddit, HN, or Discord
  • πŸ›  Build something and show us!