Giter Club home page Giter Club logo

iron's Introduction

Iron Build Status

Middleware-Oriented, Concurrency Focused Web Development in Rust.

Response Timer Example

struct ResponseTime;

impl Assoc<u64> for ResponseTime {}

impl BeforeMiddleware for ResponseTime {
    fn before(&self, req: &mut Request) -> IronResult<()> {
        req.extensions.insert::<ResponseTime, u64>(precise_time_ns());
        Ok(())
    }
}

impl AfterMiddleware for ResponseTime {
    fn after(&self, req: &mut Request, _: &mut Response) -> IronResult<()> {
        let delta = precise_time_ns() - *req.extensions.find::<ResponseTime, u64>().unwrap();
        println!("Request took: {} ms", (delta as f64) / 1000000.0);
        Ok(())
    }
}

Iron is a high level web framework built in and for Rust

Iron does not come bundled with any middleware - instead, Iron is a robust and efficient framework for plugging in middleware.

Iron focuses on providing a clean API for creating middleware and integrating them in Iron servers.

After spawning, handling a single request through Iron’s middleware stack with a single no-op middleware takes only 0.9 micro seconds - with ten middleware, it's only 1.1 microseconds.

Iron averages 17,000+ requests per second for hello world.

Iron aims to fill a void in the Rust web stack - a high level framework that is extensible and makes organizing complex server code easy.

Middleware is painless to build, and the core bundle already includes:

This allows for insanely flexible and powerful setups and allows nearly all of Iron’s features to be swappable - you can even change the middleware resolution algorithm by swapping in your own Chain.

Installation

If you're using Cargo, just add Iron to your Cargo.toml:

[dependencies.iron]

git = "https://github.com/iron/iron.git"

Otherwise, just clone this repo, cargo build, and the rlib will be in your target directory.

Along with the online documentation, you can build a local copy with cargo doc.

Check out the examples directory!

You can compile all of the examples with cargo test. The binaries will be placed in target/test/.

Get Help

One of us (@reem, @zzmp, @theptrk, @mcreinhard) is usually on #iron on the mozilla irc. Come say hi and ask any questions you might have. We are also usually on #rust and #rust-webdev.

iron's People

Contributors

reem avatar zzmp avatar michaelsproul avatar theptrk avatar brycefisher avatar cburgdorf avatar emberian avatar cengiz-io avatar mavdi avatar msierks avatar suprdewd avatar arathunku avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.