Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gsquire/limiter
Request size limiting for the Iron framework
https://github.com/gsquire/limiter
iron middleware rust
Last synced: 30 days ago
JSON representation
Request size limiting for the Iron framework
- Host: GitHub
- URL: https://github.com/gsquire/limiter
- Owner: gsquire
- License: mit
- Created: 2016-05-24T20:47:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-19T19:39:29.000Z (almost 6 years ago)
- Last Synced: 2024-10-12T22:59:36.477Z (about 1 month ago)
- Topics: iron, middleware, rust
- Language: Rust
- Homepage: https://crates.io/crates/limiter
- Size: 8.79 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# limiter
[![Build Status](https://travis-ci.org/gsquire/limiter.svg?branch=master)](https://travis-ci.org/gsquire/limiter)
This is an example of `BeforeMiddleware` for the [Iron](https://github.com/iron/iron) framework. It limits the request body size
by checking first the Content-Length header, then the size of the payload. The response is either
an HTTP 413 or it continues down the chain.It will also set an upper bound on the length of a URL which can be helpful in regular
`GET` requests.Include this in your `Cargo.toml` file:
```sh
[dependencies]
limiter = "0.3"
```## Documentation
https://docs.rs/limiter### Example
```rust
extern crate iron;
extern crate limiter;use iron::prelude::*;
use limiter::RequestLimit;
fn index(_: &mut Request) -> IronResult {
Ok(Response::with((iron::status::Ok, "Test")))
}fn main() {
let max_request = RequestLimit::default();
let mut chain = Chain::new(index);
chain.link_before(max_request);
Iron::new(chain).http("localhost:3000").unwrap();
}
```### License
MIT