Skip to content

Commit 1594944

Browse files
authored
Merge pull request iron#146 from zgtm/0.7.0-pre
Changes for the upcoming iron 0.7 release with hyper 0.12
2 parents b962c55 + fc98016 commit 1594944

File tree

7 files changed

+73
-79
lines changed

7 files changed

+73
-79
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
name = "router"
44
authors = ["Jonathan Reem <jonathan.reem@gmail.com>"]
55
license = "MIT"
6-
version = "0.6.0"
6+
version = "0.7.0-pre1"
77
description = "A router for the Iron framework."
88
repository = "https://github.com/iron/router"
99
documentation = "http://ironframework.io/doc/router/index.html"
1010
keywords = ["iron", "web", "http", "routing", "router"]
1111

1212
[dependencies]
1313
route-recognizer = "0.1"
14-
iron = "0.6"
14+
iron = { git = "https://github.com/iron/iron", branch = "master" }
1515
url = "1.1"

examples/custom_404.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ extern crate router;
55
// To use, go to http://localhost:3000/foobar to see the custom 404
66
// Or, go to http://localhost:3000 for a standard 200 OK
77

8-
use iron::{Iron, Request, Response, IronResult, AfterMiddleware, Chain};
8+
use iron::{Iron, Request, Response, IronResult, AfterMiddleware, Chain, StatusCode};
99
use iron::error::{IronError};
10-
use iron::status;
1110
use router::{Router, NoRoute};
1211

1312
struct Custom404;
@@ -17,7 +16,7 @@ impl AfterMiddleware for Custom404 {
1716
println!("Hitting custom 404 middleware");
1817

1918
if err.error.is::<NoRoute>() {
20-
Ok(Response::with((status::NotFound, "Custom 404 response")))
19+
Ok(Response::with((StatusCode::NOT_FOUND, "Custom 404 response")))
2120
} else {
2221
Err(err)
2322
}
@@ -31,9 +30,9 @@ fn main() {
3130
let mut chain = Chain::new(router);
3231
chain.link_after(Custom404);
3332

34-
Iron::new(chain).http("localhost:3000").unwrap();
33+
Iron::new(chain).http("localhost:3000");
3534
}
3635

3736
fn handler(_: &mut Request) -> IronResult<Response> {
38-
Ok(Response::with((status::Ok, "Handling response")))
37+
Ok(Response::with((StatusCode::OK, "Handling response")))
3938
}

examples/simple.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,24 @@ extern crate router;
55
// To use, go to http://localhost:3000/test and see output "test"
66
// Or, go to http://localhost:3000 to see a default "OK"
77

8-
use iron::{Iron, Request, Response, IronResult};
9-
use iron::status;
8+
use iron::{Iron, Request, Response, IronResult, StatusCode};
109
use router::{Router};
1110

1211
fn main() {
1312
let mut router = Router::new();
1413
router.get("/", handler, "handler");
1514
router.get("/:query", query_handler, "query_handler");
1615

17-
Iron::new(router).http("localhost:3000").unwrap();
16+
Iron::new(router).http("localhost:3000");
1817

1918
fn handler(_: &mut Request) -> IronResult<Response> {
20-
Ok(Response::with((status::Ok, "OK")))
19+
Ok(Response::with((StatusCode::OK, "OK")))
2120
}
2221

2322
fn query_handler(req: &mut Request) -> IronResult<Response> {
2423
let ref query = req.extensions.get::<Router>()
2524
.unwrap().find("query").unwrap_or("/");
26-
Ok(Response::with((status::Ok, *query)))
25+
Ok(Response::with((StatusCode::OK, *query)))
2726
}
2827

2928

examples/simple_with_macro.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,21 @@ extern crate router;
66
// To use, go to http://localhost:3000/test and see output "test"
77
// Or, go to http://localhost:3000 to see a default "OK"
88

9-
use iron::{Iron, Request, Response, IronResult};
10-
use iron::status;
9+
use iron::{Iron, Request, Response, IronResult, StatusCode};
1110
use router::{Router};
1211

1312
fn main() {
1413
let router = router!(root: get "/" => handler, query: get "/:query" => query_handler);
1514

16-
Iron::new(router).http("localhost:3000").unwrap();
15+
Iron::new(router).http("localhost:3000");
1716

1817
fn handler(_: &mut Request) -> IronResult<Response> {
19-
Ok(Response::with((status::Ok, "OK")))
18+
Ok(Response::with((StatusCode::OK, "OK")))
2019
}
2120

2221
fn query_handler(req: &mut Request) -> IronResult<Response> {
2322
let ref query = req.extensions.get::<Router>()
2423
.unwrap().find("query").unwrap_or("/");
25-
Ok(Response::with((status::Ok, *query)))
24+
Ok(Response::with((StatusCode::OK, *query)))
2625
}
2726
}

examples/struct_handler.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
extern crate iron;
22
extern crate router;
33

4-
use iron::Handler;
5-
use iron::status;
6-
use iron::IronResult;
7-
use iron::Response;
8-
use iron::Request;
9-
use iron::Iron;
4+
use iron::{Handler, StatusCode, IronResult, Response, Request, Iron};
105
use router::Router;
116

127
struct MessageHandler {
@@ -15,7 +10,7 @@ struct MessageHandler {
1510

1611
impl Handler for MessageHandler {
1712
fn handle(&self, _: &mut Request) -> IronResult<Response> {
18-
Ok(Response::with((status::Ok, self.message.clone())))
13+
Ok(Response::with((StatusCode::OK, self.message.clone())))
1914
}
2015
}
2116

@@ -27,5 +22,5 @@ fn main() {
2722
let mut router = Router::new();
2823
router.get("/", handler, "index");
2924

30-
Iron::new(router).http("localhost:3000").unwrap();
25+
Iron::new(router).http("localhost:3000");
3126
}

examples/url_for.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern crate iron;
88
// Go to http://localhost:3000/foo to see "foo".
99

1010
use iron::prelude::*;
11-
use iron::status;
11+
use iron::StatusCode;
1212
use router::Router;
1313

1414
fn main() {
@@ -17,11 +17,11 @@ fn main() {
1717
id_2: get "/:query" => query_handler
1818
};
1919

20-
Iron::new(router).http("localhost:3000").unwrap();
20+
Iron::new(router).http("localhost:3000");
2121

2222
fn handler(r: &mut Request) -> IronResult<Response> {
2323
Ok(Response::with((
24-
status::Ok,
24+
StatusCode::OK,
2525
format!("Please go to: {}",
2626
url_for!(r, "id_2",
2727
"query" => "test",
@@ -32,7 +32,7 @@ fn main() {
3232
fn query_handler(req: &mut Request) -> IronResult<Response> {
3333
let ref query = req.extensions.get::<Router>()
3434
.unwrap().find("query").unwrap_or("/");
35-
Ok(Response::with((status::Ok, *query)))
35+
Ok(Response::with((StatusCode::OK, *query)))
3636
}
3737

3838

0 commit comments

Comments
 (0)