An Extensible, Concurrent Web Framework for Rust

Related tags

Web Servers iron
Overview

Iron

Build Status Crates.io Status License

Extensible, Concurrency Focused Web Development in Rust.

Response Timer Example

Note: This example works with the current iron code in this repository (master branch). If you are using iron 0.6 from crates.io, please refer to the corresponding example in the branch 0.6-maintenance.

extern crate iron;
extern crate time;

use iron::prelude::*;
use iron::{typemap, AfterMiddleware, BeforeMiddleware};
use time::precise_time_ns;

struct ResponseTime;

impl typemap::Key for ResponseTime { type Value = u64; }

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

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

fn hello_world(_: &mut Request) -> IronResult<Response> {
    Ok(Response::with((iron::StatusCode::OK, "Hello World")))
}

fn main() {
    let mut chain = Chain::new(hello_world);
    chain.link_before(ResponseTime);
    chain.link_after(ResponseTime);
    Iron::new(chain).http("localhost:3000");
}

Overview

Iron is a high level web framework built in and for Rust, built on hyper. Iron is designed to take advantage of Rust's greatest features - its excellent type system and its principled approach to ownership in both single threaded and multi threaded contexts.

Iron is highly concurrent and can scale horizontally on more machines behind a load balancer or by running more threads on a more powerful machine. Iron avoids the bottlenecks encountered in highly concurrent code by avoiding shared writes and locking in the core framework.

Iron is 100% safe code:

$ rg unsafe src | wc
       0       0       0

Philosophy

Iron is meant to be as extensible and pluggable as possible; Iron's core is concentrated and avoids unnecessary features by leaving them to middleware, plugins, and modifiers.

Middleware, Plugins, and Modifiers are the main ways to extend Iron with new functionality. Most extensions that would be provided by middleware in other web frameworks are instead addressed by the much simpler Modifier and Plugin systems.

Modifiers allow external code to manipulate Requests and Response in an ergonomic fashion, allowing third-party extensions to get the same treatment as modifiers defined in Iron itself. Plugins allow for lazily-evaluated, automatically cached extensions to Requests and Responses, perfect for parsing, accessing, and otherwise lazily manipulating an http connection.

Middleware are only used when it is necessary to modify the control flow of a Request flow, hijack the entire handling of a Request, check an incoming Request, or to do final post-processing. This covers areas such as routing, mounting, static asset serving, final template rendering, authentication, and logging.

Iron comes with only basic modifiers for setting the status, body, and various headers, and the infrastructure for creating modifiers, plugins, and middleware. No plugins or middleware are bundled with Iron.

Performance

Iron averages 72,000+ requests per second for hello world and is mostly IO-bound, spending over 70% of its time in the kernel send-ing or recv-ing data.*

* Numbers from profiling on my OS X machine, your mileage may vary.

Core Extensions

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.

Extensions are painless to build. Some important ones are:

Middleware:

Plugins:

Both:

This allows for extremely 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.

* Due to the rapidly evolving state of the Rust ecosystem, not everything builds all the time. Please be patient and file issues for breaking builds, we're doing our best.

Underlying HTTP Implementation

Iron is based on and uses hyper as its HTTP implementation, and lifts several types from it, including its header representation, status, and other core HTTP types. It is usually unnecessary to use hyper directly when using Iron, since Iron provides a facade over hyper's core facilities, but it is sometimes necessary to depend on it as well.

Installation

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

[dependencies.iron]
version = "*"

Documentation

The documentation is hosted online and auto-updated with each successful release. You can also use cargo doc to build a local copy.

Examples

Check out the examples directory!

You can run an individual example using cargo run --bin example-name inside the examples directory. Note that for benchmarking you should make sure to use the --release flag, which will cause cargo to compile the entire toolchain with optimizations. Without --release you will get truly sad numbers.

Getting Help

Feel free to ask questions as github issues in this or other related repos.

The best place to get immediate help is on IRC, on any of these channels on the mozilla network:

  • #rust-webdev
  • #iron
  • #rust

One of the maintainers or contributors is usually around and can probably help. We encourage you to stop by and say hi and tell us what you're using Iron for, even if you don't have any questions. It's invaluable to hear feedback from users and always nice to hear if someone is using the framework we've worked on.

Maintainers

Jonathan Reem (reem) is the core maintainer and author of Iron.

Commit Distribution (as of 8e55759):

Jonathan Reem (415)
Zach Pomerantz (123)
Michael Sproul (9)
Patrick Tran (5)
Corey Richardson (4)
Bryce Fisher-Fleig (3)
Barosl Lee (2)
Christoph Burgdorf (2)
da4c30ff (2)
arathunku (1)
Cengiz Can (1)
Darayus (1)
Eduardo Bautista (1)
Mehdi Avdi (1)
Michael Sierks (1)
Nerijus Arlauskas (1)
SuprDewd (1)

License

MIT

Comments
  • Async Iron with Hyper tokio using a cpupool.

    Async Iron with Hyper tokio using a cpupool.

    This PR is the start of me working on porting Iron over to async Hyper/tokio (issue #501). This RFC start just moves everything to compile on the new branch.

    I don't know if you want to accept this PR (after whatever cleanup is necessary!) as a base so someone (maybe me if my time stays available) can start working on a proper async story for Iron. If you prefer this PR develops into the full async support, that's fine too I'll just leave it open as I continue developing.

    opened by MJDSys 33
  • greate performance degradation

    greate performance degradation

    I decided to repeat wrk test for helloworld from documentation on my computer. I had rust 1.2 and such result:

    wrk -t12 -c900 -d10s http://127.0.0.1:3000/ Running 10s test @ http://127.0.0.1:3000/ 12 threads and 900 connections Thread Stats Avg Stdev Max +/- Stdev Latency 170.13us 113.36us 6.43ms 92.11% Req/Sec 18.21k 2.24k 22.49k 73.27% 182872 requests in 10.08s, 19.88MB read Socket errors: connect 0, read 0, write 0, timeout 2 Requests/sec: 18145.14 Transfer/sec: 1.97MB

    18k RPS - not bad.

    Than I decided to uprade rust to 1.3 and compare performance. Also I deleted Cargo.lock to get the latest version of packets. Now a have very bad performance:

    wrk -t12 -c900 -d10s http://127.0.0.1:3000/
    Running 10s test @ http://127.0.0.1:3000/ 12 threads and 900 connections Thread Stats Avg Stdev Max +/- Stdev Latency 30.76ms 42.62ms 218.86ms 95.56% Req/Sec 155.19 172.17 604.00 80.77% 901 requests in 10.07s, 100.31KB read Socket errors: connect 0, read 1, write 0, timeout 0 Requests/sec: 89.45 Transfer/sec: 9.96KB

    89 RPS? What did happen? My current Cargo.lock: [root] name = "web_server" version = "0.1.0" dependencies = [ "iron 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "advapi32-sys" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "bitflags" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index"

    [[package]] name = "conduit-mime-types" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "cookie" version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "openssl 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "error" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "traitobject 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "gcc" version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "hpack" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "httparse" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index"

    [[package]] name = "hyper" version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cookie 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "language-tags 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "solicit 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "traitobject 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "iron" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "conduit-mime-types 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "error 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "modifier 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "kernel32-sys" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "language-tags" version = "0.0.7" source = "registry+https://github.com/rust-lang/crates.io-index"

    [[package]] name = "lazy_static" version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index"

    [[package]] name = "libc" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index"

    [[package]] name = "libressl-pnacl-sys" version = "2.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "pnacl-build-helper 1.4.10 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "log" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "matches" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index"

    [[package]] name = "mime" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "modifier" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index"

    [[package]] name = "num_cpus" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "openssl" version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "openssl-sys" version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libressl-pnacl-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "pkg-config" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index"

    [[package]] name = "plugin" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "pnacl-build-helper" version = "1.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "rand" version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "rustc-serialize" version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index"

    [[package]] name = "solicit" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hpack 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "tempdir" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rand 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "time" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "traitobject" version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index"

    [[package]] name = "traitobject" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index"

    [[package]] name = "typeable" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index"

    [[package]] name = "typemap" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unsafe-any 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "unicase" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index"

    [[package]] name = "unsafe-any" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "traitobject 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "url" version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", ]

    [[package]] name = "winapi" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index"

    [[package]] name = "winapi-build" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index"

    opened by sergei-iurchenko 23
  • (feat) Provide a useful interface to Request URL data.

    (feat) Provide a useful interface to Request URL data.

    Exposing a url::Url is less than ideal as we know the URL will always be in a relative scheme like HTTP or HTTPS.

    @SimonSapin's rust-url strictly adheres to the WhatWG URL spec, so I don't think we can expect upstream changes for our own convenience.

    To provide Iron users with a friendlier interface for HTTP and HTTPS URLs, I think we should wrap a url::Url. In order to minimise the use of {Option,Result}::unwrap these are the features I would like to add to the wrapper:

    • A method to retrieve the port as a 32-bit integer. HTTP and HTTPS have well defined default ports which can be returned in the case where no port is explicitly provided. The url::Url::port method returns an Option<&str>, which is guaranteed to be Some for relative schemes. It can be empty, in the case of a file:// scheme, but seeing as we're writing a web server, we should be able to safely unwrap the return value of std​::i32​::parse_bytes.
    • A method to retrieve the username as an Option<&str>. The URL spec dictates that usernames are possibly empty strings, so rust-url just provides a username: String field inside the RelativeSchemeData struct. For parsing purposes the presence of an @ character is irrelevant: http://example.com and http://@example.com parse the same and yeild a username field equal to "". I'm tempted to map the empty string to None to be more Rust-like, and to remain consistent with the password accessor. One thing to note is that url::Url::username returns an Option<&str>, but it's only None in the case of a non-relative scheme like data:.
    • A method to retrieve the password as an Option<&str>. Just return a reference to the password field from the relative scheme data (equivalent to calling url::Url::password, but with one less match).
    • A method to retrieve the host as a url::Host. Use RelativeSchemeData::host.
    • A method to retrieve the path as a &[String]. Use RelativeSchemeData::path.
    • A method to retrieve the query as an Option<&str>. Use Url::query.
    • A method to retrieve the fragment as an Option<&str>. Use Url::fragment.

    Unresolved issues:

    • What do we do about domain?
    • What should we call the wrapper class? WebURL seems kind of appropriate, but not perfect.
    • Should we use stronger types for any of the fields? Username(&str), Password(&str), etc?
    opened by michaelsproul 21
  • Completely rewrite the Error system

    Completely rewrite the Error system

    Lots and lots of changes here - the commits are pretty linear and should have good descriptions, you can also just read the docs for IronError and the middleware module, which explain the new situation pretty well.

    Also big changes to the README, which finally got a much needed cleanup.

    Chain the trait is gone, ChainBuilder => Chain

    [breaking-change]

    Fixes #272 Fixes #186

    enhancement high-priority feature 
    opened by reem 19
  • Build Failure

    Build Failure

    Trying to use Rust on Ubuntu 14.10, I get this error:

    $ cargo build                                                                                                                                                                                                                                                     
       Compiling mucell v0.1.10
       Compiling plugin v0.2.0
       Compiling openssl-sys v0.2.16
       Compiling time v0.1.12
       Compiling mime v0.0.6
    ../../.cargo/registry/src/github.com-1285ae84e5963aae/mucell-0.1.10/src/lib.rs:99:14: 99:28 error: use of undeclared type name `marker::NoSync`
    ../../.cargo/registry/src/github.com-1285ae84e5963aae/mucell-0.1.10/src/lib.rs:99     noshare: marker::NoSync,
    ../../.cargo/registry/src/github.com-1285ae84e5963aae/mucell-0.1.10/src/lib.rs:112:22: 112:36 error: unresolved name `marker::NoSync`
    ../../.cargo/registry/src/github.com-1285ae84e5963aae/mucell-0.1.10/src/lib.rs:112             noshare: marker::NoSync,
    
    error: aborting due to 2 previous errors
    Build failed, waiting for other jobs to finish...
    Could not compile `mucell`.
    
    To learn more, run the command again with --verbose.
    

    My rust version is:

    $ rustc --version
    rustc 1.0.0-nightly (ed530d7a3 2015-01-16 22:41:16 +0000)
    

    My cargo.toml file:

    [package]
    
    name = "test_rust_web"
    version = "0.0.1"
    authors = ["Bernardo Heynemann <[email protected]>"]
    
    [dependencies]
    iron = "*"
    

    Anything I'm doing wrong?

    Thanks for any help. Big Rust newbie here.

    opened by heynemann 19
  • Decide on session middleware

    Decide on session middleware

    It appears that there are currently four (!!!) session middleware implementations available:

    • https://crates.io/crates/iron_session by @dgriffen

      Appears to store session data in RAM

    • https://crates.io/crates/session by @hikelee

      Redis as backend

    • https://crates.io/crates/iron-sessionstorage by me

      Generic backend trait, signed cookie backend implemented. Theoretically the user could write a redis backend and plug it in

    • https://github.com/iron/session, the current official one

      Generic backend trait as well, but with current API not possible to implement signed cookie backend. Default impl stores session data in RAM

    We should probably find a consensus on those...

    opened by untitaker 18
  • New Maintainers

    New Maintainers

    Hey,

    I would like to suggest looking for new maintainers rather than recommending to fork iron (as in #576). I don't think a fork would gain the popularity of iron in any reasonable amount of time. This framework has done so much right and I think it is important to have a web framework that is based on another concept than Rocket for example.

    What about changing the "NOTE: Iron is not actively maintained at the moment, please consider using a different framework" to "NOTE: Iron is looking for maintainers." and maybe let people express their interest in maintaining iron in this issue? I think there are quite some future maintainers that just need to know their wanted for this project.

    I want to set a good example by saying "I am very interested in maintaining iron!".

    @reem @zzmp @untitaker

    question 
    opened by phlmn 15
  • (feat) Add ability to serve over HTTPS.

    (feat) Add ability to serve over HTTPS.

    This adds a security property to iron::Iron, defaulting to 'Insecure'. Setting it to 'Secure' and specifying certificate and key paths allows the server to use HTTPS.

    Also fix a FIXME in Request::from_http now that HTTPS connections are possible.

    opened by cyndis 15
  • (refactor) Change all the things

    (refactor) Change all the things

    This PR is a wide-reaching, fundamental refactor to the way Iron works.

    It includes these changes, but probably more. I recommend reading the source if you want an exhaustive list of changes. I will detail all of the changes in a blog post in the near future.

    • enter/exit -> before/after
    • introduces Handler and removes special treatment of Chain
    • Clone -> Send + Sync
    • Alloy -> Plugins
    • Better Error system and the error type from rust-error
    • various other things about the place

    Not ready to merge. Waiting on further changes and debugging.

    in progress 
    opened by reem 14
  • ssl feature is not documented in online docs

    ssl feature is not documented in online docs

    Struggling to figure out how to start up Iron with HTTPS rather than the default HTTP. Do we also need to provide security certificates, or is that generated by Hyper?

    bug documentation 
    opened by vignesh-sankaran 12
  • fn is no longer cloneable

    fn is no longer cloneable

    This is due to the implicit bound lifetimes in &mut. See https://github.com/rust-lang/rust/issues/14820

    Until this is fixed upstream, we'll need to have a wrapper for functions. Essentially, that is what middleware is, so this merits discussion.

    If we do, it can be something like pub struct MiddleFn(fn (&mut ...) -> Status), where we will impl Clone for MiddleFn and impl Middleware for MiddleFn.

    I'll work on a PR tonight, and we can discuss in the AM. I do not think we should implement a workaround, instead striking the function impl of Middleware from iron. This will avoid having to deprecate the workaround struct in the future, and prevent code bloat.

    opened by zzmp 12
  • Should this crate be used anymore ?

    Should this crate be used anymore ?

    Hi @phlmn @untitaker

    e.g. outdated dependencies - hyper is now 0.14 series and I'm seeing a new project brings in hyper 0.10.16

    Also there are issues like https://github.com/iron/iron/issues/575 I am not sure if resolved as I didn't investigate yet.

    Wonder if this crate will receive any future maintenance including security fixes - if any in the future or whether this crate is deprecated ?

    I already tried to chase @reem earlier

    Cheers

    opened by pinkforest 1
  • stop|restart an Iron server

    stop|restart an Iron server

    Hi. Is there a way to gracefully stop an Iron running server? My app spawns a new thread to start an Iron HTTP server. It supports dynamic configuration reload and I want to restart its HTTP server with new configuration (e.g. new port number). When the new thread starts an Iron server, Iron server blocks the thread so the thread can not receive parent events to update the server.

    opened by pouriya 0
  • Add stale-while-revalidate to CacheDirective

    Add stale-while-revalidate to CacheDirective

    https://docs.rs/iron/0.6.1/iron/headers/enum.CacheDirective.html

    https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#cache_directives

    It looks like CacheDirective is missing:

    s-maxage must-understand immutable stale-while-revalidate stale-if-error

    I'd like to be able to use stale-while-revalidate in docs.rs: https://github.com/rust-lang/docs.rs/issues/845#issuecomment-980837833. Would you be willing to add these variants? Thanks!

    opened by jsha 0
  • Tests error with latest Rust 1.49

    Tests error with latest Rust 1.49

    On Fedora Rawhide with Rust 1.49:

    test middleware::test::test_chain_handler_error_then_handle ... FAILED
    test middleware::test::test_chain_before_error ... FAILED
    test middleware::test::test_chain_before_error_then_handle ... FAILED
    test middleware::test::test_chain_normal ... FAILED
    failures:
    ---- middleware::test::test_chain_after_error stdout ----
    thread 'middleware::test::test_chain_after_error' panicked at 'attempted to leave type `request::Body` uninitialized, which is invalid', /builddir/build/BUILD/rustc-1.49.0-src/library/core/src/mem/mod.rs:659:9
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    ---- middleware::test::test_chain_handler_error stdout ----
    thread 'middleware::test::test_chain_handler_error' panicked at 'attempted to leave type `request::Body` uninitialized, which is invalid', /builddir/build/BUILD/rustc-1.49.0-src/library/core/src/mem/mod.rs:659:9
    ---- middleware::test::test_chain_after_error_then_handle stdout ----
    thread 'middleware::test::test_chain_after_error_then_handle' panicked at 'attempted to leave type `request::Body` uninitialized, which is invalid', /builddir/build/BUILD/rustc-1.49.0-src/library/core/src/mem/mod.rs:659:9
    ---- middleware::test::test_chain_handler_error_then_handle stdout ----
    thread 'middleware::test::test_chain_handler_error_then_handle' panicked at 'attempted to leave type `request::Body` uninitialized, which is invalid', /builddir/build/BUILD/rustc-1.49.0-src/library/core/src/mem/mod.rs:659:9
    ---- middleware::test::test_chain_before_error stdout ----
    thread 'middleware::test::test_chain_before_error' panicked at 'attempted to leave type `request::Body` uninitialized, which is invalid', /builddir/build/BUILD/rustc-1.49.0-src/library/core/src/mem/mod.rs:659:9
    ---- middleware::test::test_chain_before_error_then_handle stdout ----
    thread 'middleware::test::test_chain_before_error_then_handle' panicked at 'attempted to leave type `request::Body` uninitialized, which is invalid', /builddir/build/BUILD/rustc-1.49.0-src/library/core/src/mem/mod.rs:659:9
    ---- middleware::test::test_chain_normal stdout ----
    thread 'middleware::test::test_chain_normal' panicked at 'attempted to leave type `request::Body` uninitialized, which is invalid', /builddir/build/BUILD/rustc-1.49.0-src/library/core/src/mem/mod.rs:659:9
    failures:
        middleware::test::test_chain_after_error
        middleware::test::test_chain_after_error_then_handle
        middleware::test::test_chain_before_error
        middleware::test::test_chain_before_error_then_handle
        middleware::test::test_chain_handler_error
        middleware::test::test_chain_handler_error_then_handle
        middleware::test::test_chain_normal
    test result: FAILED. 13 passed; 7 failed; 0 ignored; 0 measured; 0 filtered out
    

    I believe this is due to this change: https://github.com/rust-lang/rust/issues/66151#issue-518365336

    opened by eclipseo 0
Owner
Flexible middleware-oriented server development in Rust. For old repos see http://github.com/iron-graveyard
null
Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.

Actix Web Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust Features Supports HTTP/1.x and HTTP/2 Streaming and pipelining

Actix 16.3k Jan 8, 2023
An expressjs inspired web framework for Rust

nickel.rs nickel.rs is a simple and lightweight foundation for web applications written in Rust. Its API is inspired by the popular express framework

null 3k Jan 3, 2023
A web framework for Rust.

Rocket Rocket is an async web framework for Rust with a focus on usability, security, extensibility, and speed. #[macro_use] extern crate rocket; #[g

Sergio Benitez 19.5k Jan 8, 2023
A lightweight web framework built on hyper, implemented in Rust language.

Sapper Sapper, a lightweight web framework, written in Rust. Sapper focuses on ergonomic usage and rapid development. It can work with stable Rust. Sa

Daogang Tang 622 Oct 27, 2022
Web framework in Rust

Rouille, a Rust web micro-framework Rouille is a micro-web-framework library. It creates a listening socket and parses incoming HTTP requests from cli

Pierre Krieger 840 Jan 1, 2023
A fast, boilerplate free, web framework for Rust

Tower Web A web framework for Rust with a focus on removing boilerplate. API Documentation Tower Web is: Fast: Fully asynchronous, built on Tokio and

Carl Lerche 969 Dec 22, 2022
Sincere is a micro web framework for Rust(stable) based on hyper and multithreading

The project is no longer maintained! Sincere Sincere is a micro web framework for Rust(stable) based on hyper and multithreading. Style like koa. The

null 94 Oct 26, 2022
Salvo is a powerful and simplest web server framework in Rust world

Salvo is an extremely simple and powerful Rust web backend framework. Only basic Rust knowledge is required to develop backend services.

Salvo 1.2k Jan 5, 2023
The light web framework for Rust.

Rusty Web Rusty web is a simple to use, fully customizable lightweight web framework for rust developers. Learn rusty web Installation [dependencies]

Tej Magar 5 Feb 27, 2024
A flexible web framework that promotes stability, safety, security and speed.

A flexible web framework that promotes stability, safety, security and speed. Features Stability focused. All releases target stable Rust. This will n

Gotham 2.1k Jan 3, 2023
Handlebars middleware for Iron web framework

handlebars-iron Handlebars middleware for the Iron web framework. This library, together with handlebars, iron and hyper, works on both stable and nig

Ning Sun 118 Jun 28, 2022
A toy web framework inspired by gin-gonic/gin and expressjs/express.

Rum Framework A toy web framework inspired by gin-gonic/gin and expressjs/express. Installation Just add rum_framework to the dependencies of Cargo.to

Hidetomo Kou(YingZhi 2 Dec 20, 2022
JSON Web Token implementation in Rust.

Frank JWT Implementation of JSON Web Tokens in Rust. Algorithms and features supported HS256 HS384 HS512 RS256 RS384 RS512 ES256 ES384 ES512 Sign Veri

Alex Maslakov 246 Dec 27, 2022
Source Code for 'Practical Rust Web Projects' by Shing Lyu

Apress Source Code This repository accompanies Practical Rust Web Projects by Shing Lyu (Apress, 2021). Download the files as a zip using the green bu

Apress 44 Nov 17, 2022
A web application completely written in Rust. 🌍

WebApp.rs A web application completely written in Rust Target of this project is to write a complete web application including backend and frontend wi

Sascha Grunert 2.1k Dec 30, 2022
Web Server made with Rust - for learning purposes

Web Server made with Rust - for learning purposes

Lílian 2 Apr 25, 2022
Archibald is my attempt at learning Rust and writing a HTTP 1.1 web server.

Archibald To be a butler, is to be able to maintain an even-temper, at all times. One must have exceptional personal hygiene and look sharp and profes

Daniel Cuthbert 4 Jun 20, 2022
VRS is a simple, minimal, free and open source static web server written in Rust

VRS is a simple, minimal, free and open source static web server written in Rust which uses absolutely no dependencies and revolves around Rust's std::net built-in utility.

null 36 Nov 8, 2022
Example Blog using Rust, Actix Web, HTMX, Mustache

Actix Blog An example blog built with Actix. It uses htmx and handlebar templates. Running To run the blog, you need to have a recent version of Rust

Dru Jensen 2 Nov 11, 2022