{"id":13440209,"url":"https://github.com/iron/iron","last_synced_at":"2025-05-07T11:52:26.323Z","repository":{"id":17810852,"uuid":"20702627","full_name":"iron/iron","owner":"iron","description":"An Extensible, Concurrent Web Framework for Rust","archived":false,"fork":false,"pushed_at":"2024-06-14T21:59:09.000Z","size":1046,"stargazers_count":6124,"open_issues_count":58,"forks_count":400,"subscribers_count":156,"default_branch":"master","last_synced_at":"2025-04-22T18:03:23.949Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-06-10T21:37:29.000Z","updated_at":"2025-04-20T03:34:35.000Z","dependencies_parsed_at":"2024-11-18T09:45:55.744Z","dependency_job_id":null,"html_url":"https://github.com/iron/iron","commit_stats":{"total_commits":1202,"total_committers":157,"mean_commits":7.656050955414012,"dds":"0.49417637271214643","last_synced_commit":"cde77e5e0e9bfa1bf1230f4bdd8491f4f4cdc72c"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iron%2Firon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iron%2Firon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iron%2Firon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iron%2Firon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iron","download_url":"https://codeload.github.com/iron/iron/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252873972,"owners_count":21817710,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T03:01:20.732Z","updated_at":"2025-05-07T11:52:26.296Z","avatar_url":"https://github.com/iron.png","language":"Rust","readme":"# Iron\n\n[![Build Status](https://secure.travis-ci.org/iron/iron.svg?branch=master)](https://travis-ci.org/iron/iron)\n[![Crates.io Status](http://meritbadge.herokuapp.com/iron)](https://crates.io/crates/iron)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/iron/iron/master/LICENSE)\n\n\u003e Extensible, Concurrency Focused Web Development in Rust.\n\n## Response Timer Example\n\nNote: 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](https://github.com/iron/iron/blob/0.6-maintenance/README.md) in the branch [0.6-maintenance](https://github.com/iron/iron/tree/0.6-maintenance).\n\n```rust\nextern crate iron;\nextern crate time;\n\nuse iron::prelude::*;\nuse iron::{typemap, AfterMiddleware, BeforeMiddleware};\nuse time::precise_time_ns;\n\nstruct ResponseTime;\n\nimpl typemap::Key for ResponseTime { type Value = u64; }\n\nimpl BeforeMiddleware for ResponseTime {\n    fn before(\u0026self, req: \u0026mut Request) -\u003e IronResult\u003c()\u003e {\n        req.extensions.insert::\u003cResponseTime\u003e(precise_time_ns());\n        Ok(())\n    }\n}\n\nimpl AfterMiddleware for ResponseTime {\n    fn after(\u0026self, req: \u0026mut Request, res: Response) -\u003e IronResult\u003cResponse\u003e {\n        let delta = precise_time_ns() - *req.extensions.get::\u003cResponseTime\u003e().unwrap();\n        println!(\"Request took: {} ms\", (delta as f64) / 1000000.0);\n        Ok(res)\n    }\n}\n\nfn hello_world(_: \u0026mut Request) -\u003e IronResult\u003cResponse\u003e {\n    Ok(Response::with((iron::StatusCode::OK, \"Hello World\")))\n}\n\nfn main() {\n    let mut chain = Chain::new(hello_world);\n    chain.link_before(ResponseTime);\n    chain.link_after(ResponseTime);\n    Iron::new(chain).http(\"localhost:3000\");\n}\n```\n\n## Overview\n\nIron is a high level web framework built in and for Rust, built on\n[hyper](https://github.com/hyperium/hyper). Iron is designed to take advantage\nof Rust's greatest features - its excellent type system and its principled\napproach to ownership in both single threaded and multi threaded contexts.\n\nIron is highly concurrent and can scale horizontally on more machines behind a\nload balancer or by running more threads on a more powerful machine. Iron\navoids the bottlenecks encountered in highly concurrent code by avoiding shared\nwrites and locking in the core framework.\n\nIron is 100% safe code:\n\n```sh\n$ rg unsafe src | wc\n       0       0       0\n```\n\n## Philosophy\n\nIron is meant to be as extensible and pluggable as possible; Iron's core is\nconcentrated and avoids unnecessary features by leaving them to middleware,\nplugins, and modifiers.\n\nMiddleware, Plugins, and Modifiers are the main ways to extend Iron with new\nfunctionality. Most extensions that would be provided by middleware in other\nweb frameworks are instead addressed by the much simpler Modifier and Plugin\nsystems.\n\nModifiers allow external code to manipulate Requests and Response in an ergonomic\nfashion, allowing third-party extensions to get the same treatment as modifiers\ndefined in Iron itself. Plugins allow for lazily-evaluated, automatically cached\nextensions to Requests and Responses, perfect for parsing, accessing, and\notherwise lazily manipulating an http connection.\n\nMiddleware are only used when it is necessary to modify the control flow of a\nRequest flow, hijack the entire handling of a Request, check an incoming\nRequest, or to do final post-processing. This covers areas such as routing,\nmounting, static asset serving, final template rendering, authentication, and\nlogging.\n\nIron comes with only basic modifiers for setting the status, body, and various\nheaders, and the infrastructure for creating modifiers, plugins, and\nmiddleware. No plugins or middleware are bundled with Iron.\n\n## Performance\n\nIron averages [72,000+ requests per second for hello world](https://github.com/iron/iron/wiki/How-to-Benchmark-hello.rs-Example)\nand is mostly IO-bound, spending over 70% of its time in the kernel send-ing or\nrecv-ing data.\\*\n\n\\* _Numbers from profiling on my OS X machine, your mileage may vary._\n\n## Core Extensions\n\nIron aims to fill a void in the Rust web stack - a high level framework that is\n_extensible_ and makes organizing complex server code easy.\n\nExtensions are painless to build. Some important ones are:\n\nMiddleware:\n\n- [Routing](https://github.com/iron/router)\n- [Mounting](https://github.com/iron/mount)\n- [Static File Serving](https://github.com/iron/staticfile)\n- [Logging](https://github.com/iron/logger)\n\nPlugins:\n\n- [JSON Body Parsing](https://github.com/iron/body-parser)\n- [URL Encoded Data Parsing](https://github.com/iron/urlencoded)\n- [All-In-One (JSON, URL, \u0026 Form Data) Parameter Parsing](https://github.com/iron/params)\n\nBoth:\n\n- [Shared Memory (also used for Plugin configuration)](https://github.com/iron/persistent)\n- [Sessions](https://github.com/iron/iron-sessionstorage)\n\nThis allows for extremely flexible and powerful setups and allows nearly all\nof Iron's features to be swappable - you can even change the middleware\nresolution algorithm by swapping in your own `Chain`.\n\n\\* Due to the rapidly evolving state of the Rust ecosystem, not everything\nbuilds all the time. Please be patient and file issues for breaking builds,\nwe're doing our best.\n\n## Underlying HTTP Implementation\n\nIron is based on and uses [`hyper`](https://github.com/hyperium/hyper) as its\nHTTP implementation, and lifts several types from it, including its header\nrepresentation, status, and other core HTTP types. It is usually unnecessary to\nuse `hyper` directly when using Iron, since Iron provides a facade over\n`hyper`'s core facilities, but it is sometimes necessary to depend on it as\nwell.\n\n\u003c!--\nFIXME: expand on when it is necessary to user hyper for serving,\ne.g. when doing HTTPS.\n--\u003e\n\n## Installation\n\nIf you're using `Cargo`, just add Iron to your `Cargo.toml`:\n\n```toml\n[dependencies.iron]\nversion = \"*\"\n```\n\n## [Documentation](https://docs.rs/iron)\n\nThe documentation is hosted [online](https://docs.rs/iron) and\nauto-updated with each successful release. You can also use `cargo doc` to\nbuild a local copy.\n\n## [Examples](/examples)\n\nCheck out the [examples](/examples) directory!\n\nYou can run an individual example using `cargo run --bin example-name` inside\nthe [examples](/examples) directory. Note that for benchmarking you should make\nsure to use the `--release` flag, which will cause cargo to compile the entire\ntoolchain with optimizations. Without `--release` you will get truly sad numbers.\n\n## Getting Help\n\nFeel free to ask questions as github issues in this or other related repos.\n\nThe best place to get immediate help is on IRC, on any of these channels on the\nmozilla network:\n\n- `#rust-webdev`\n- `#iron`\n- `#rust`\n\nOne of the maintainers or contributors is usually around and can probably help.\nWe encourage you to stop by and say hi and tell us what you're using Iron for,\neven if you don't have any questions. It's invaluable to hear feedback from users\nand always nice to hear if someone is using the framework we've worked on.\n\n## Maintainers\n\nJonathan Reem ([reem](https://github.com/reem)) is the core maintainer and\nauthor of Iron.\n\nCommit Distribution (as of `8e55759`):\n\n```\nJonathan Reem (415)\nZach Pomerantz (123)\nMichael Sproul (9)\nPatrick Tran (5)\nCorey Richardson (4)\nBryce Fisher-Fleig (3)\nBarosl Lee (2)\nChristoph Burgdorf (2)\nda4c30ff (2)\narathunku (1)\nCengiz Can (1)\nDarayus (1)\nEduardo Bautista (1)\nMehdi Avdi (1)\nMichael Sierks (1)\nNerijus Arlauskas (1)\nSuprDewd (1)\n```\n\n## License\n\nMIT\n","funding_links":[],"categories":["Libraries","Rust","库 Libraries","库","\u003ca name=\"Rust\"\u003e\u003c/a\u003eRust"],"sub_categories":["Web programming","网络编程 Web programming","网页编程","Misc","web编程 Web programming"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firon%2Firon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Firon%2Firon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firon%2Firon/lists"}