-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 20d97cd
Showing
7 changed files
with
586 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
target | ||
Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Contributing | ||
|
||
**params** uses the same conventions as **[Iron](https://github.com/iron/iron)**. | ||
|
||
### Overview | ||
|
||
* Fork body-parser to your own account | ||
* Create a feature branch, namespaced by. | ||
* bug/... | ||
* feat/... | ||
* test/... | ||
* doc/... | ||
* refactor/... | ||
* Make commits to your feature branch. Prefix each commit like so: | ||
* (feat) Added a new feature | ||
* (fix) Fixed inconsistent tests [Fixes #0] | ||
* (refactor) ... | ||
* (cleanup) ... | ||
* (test) ... | ||
* (doc) ... | ||
* Make a pull request with your changes directly to master. Include a | ||
description of your changes. | ||
* Wait for one of the reviewers to look at your code and either merge it or | ||
give feedback which you should adapt to. | ||
|
||
#### Thank you for contributing! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "params" | ||
version = "0.0.1" | ||
authors = ["Skyler Lipthay <[email protected]>"] | ||
description = "A multi-source request parameters parser for Iron." | ||
readme = "README.md" | ||
license = "MIT" | ||
repository = "https://github.com/iron/params" | ||
documentation = "http://ironframework.io/doc/params/index.html" | ||
|
||
[dependencies] | ||
bodyparser = "*" | ||
formdata = { git = "https://github.com/SkylerLipthay/formdata" } | ||
iron = "*" | ||
plugin = "*" | ||
rustc-serialize = "*" | ||
urlencoded = "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 iron | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# params | ||
|
||
A plugin for the [Iron](https://github.com/iron/iron) web framework that parses parameters from incoming requests from the following sources: | ||
|
||
* JSON data (`Content-Type: application/json`) | ||
* URL-encoded GET parameters | ||
* URL-encoded `Content-Type: application/x-www-form-urlencoded` parameters | ||
* Multipart form data (`Content-Type: multipart/form-data`) | ||
|
||
See `examples/params.rs` for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
extern crate iron; | ||
extern crate params; | ||
|
||
use iron::prelude::*; | ||
use iron::status; | ||
use params::Params; | ||
|
||
fn handle(req: &mut Request) -> IronResult<Response> { | ||
println!("{:?}", req.get_ref::<Params>()); | ||
Ok(Response::with(status::Ok)) | ||
} | ||
|
||
// Execute the following cURL requests and watch your terminal for the parsed parameters. | ||
// | ||
// `curl -i "localhost:3000" -H "Content-Type: application/json" -d '{"name":"jason","age":2}'` | ||
// => Ok({"age": U64(2), "name": String("jason")}) | ||
// | ||
// `curl -i -X POST "http://localhost:3000/" --data "fruit=apple&name=iron&fruit=pear"` | ||
// => Ok({"fruit": String("pear"), "name": String("iron")}) | ||
// | ||
// `curl -i "http://localhost:3000/?x\[\]=1&x\[\]=2" -F "images[]=@/path/to/file.jpg"` | ||
// => Ok({ | ||
// "images": Array([File(UploadedFile { | ||
// path: "/tmp/path/to/file.jpg", | ||
// filename: Some("file.jpg"), | ||
// content_type: Mime(Image, Jpeg, []), | ||
// size: 1234 | ||
// })]), | ||
// "x": Array([String("1"), String("2")]) | ||
// }) | ||
// | ||
// `curl -i -X POST "http://localhost:3000/" --data "x[][]=2"` | ||
// => Err(InvalidPath) | ||
fn main() { | ||
Iron::new(Chain::new(handle)).http("localhost:3000").unwrap(); | ||
} |
Oops, something went wrong.