Update serde in examples.

This commit is contained in:
Sergio Benitez 2016-10-03 17:56:43 -07:00
parent 9cf23ae2d4
commit 920bd35d46
8 changed files with 25 additions and 25 deletions

View File

@ -9,4 +9,4 @@ rocket = { path = "../../lib" }
rocket_codegen = { path = "../../codegen" }
serde = "0.8"
serde_json = "0.8"
serde_macros = "0.8"
serde_derive = "0.8"

View File

@ -1,8 +1,9 @@
#![feature(plugin, custom_derive)]
#![plugin(rocket_codegen, serde_macros)]
#![feature(plugin, rustc_macro)]
#![plugin(rocket_codegen)]
extern crate rocket;
extern crate serde_json;
#[macro_use] extern crate serde_derive;
use rocket::{Rocket, Request, Error};
use rocket::http::ContentType;
@ -26,18 +27,14 @@ fn hello(content_type: ContentType, name: String, age: i8) -> data::JSON<String>
}
#[error(404)]
fn not_found<'r>(error: Error, request: &'r Request<'r>) -> String {
match error {
Error::BadMethod if !request.content_type().is_json() => {
format!("<p>This server only supports JSON requests, not '{}'.</p>",
request.content_type())
}
Error::NoRoute => {
format!("<p>Sorry, '{}' is not a valid path!</p>
fn not_found<'r>(_: Error, request: &'r Request<'r>) -> String {
if !request.content_type().is_json() {
format!("<p>This server only supports JSON requests, not '{}'.</p>",
request.content_type())
} else {
format!("<p>Sorry, '{}' is not a valid path!</p>
<p>Try visiting /hello/&lt;name&gt;/&lt;age&gt; instead.</p>",
request.uri())
}
_ => format!("<p>Bad Request</p>"),
}
}

View File

@ -8,7 +8,7 @@ workspace = "../../"
rocket = { path = "../../lib" }
rocket_codegen = { path = "../../codegen" }
serde = "*"
serde_macros = "*"
serde_derive = "*"
serde_json = "*"
[dependencies.rocket_contrib]

View File

@ -1,9 +1,10 @@
#![feature(plugin, custom_derive)]
#![plugin(rocket_codegen, serde_macros)]
#![feature(plugin, rustc_macro)]
#![plugin(rocket_codegen)]
extern crate rocket_contrib;
extern crate rocket;
extern crate serde_json;
#[macro_use] extern crate serde_derive;
use rocket::{Rocket, Request, Error};
use rocket::response::Redirect;

View File

@ -9,7 +9,7 @@ rocket = { path = "../../lib" }
rocket_codegen = { path = "../../codegen" }
serde = "*"
serde_json = "*"
serde_macros = "*"
serde_derive = "*"
lazy_static = "*"
[dependencies.rocket_contrib]

View File

@ -1,10 +1,11 @@
#![feature(plugin, custom_derive)]
#![plugin(rocket_codegen, serde_macros)]
#![feature(plugin, rustc_macro)]
#![plugin(rocket_codegen)]
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate rocket_contrib;
extern crate rocket;
extern crate serde_json;
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate rocket_contrib;
#[macro_use] extern crate serde_derive;
use rocket::{Rocket, Request, Error};
use rocket_contrib::JSON;

View File

@ -10,7 +10,7 @@ rocket_codegen = { path = "../../codegen" }
lazy_static = "*"
serde = "0.8"
serde_json = "0.8"
serde_macros = "0.8"
serde_derive = "0.8"
diesel = { git = "https://github.com/SergioBenitez/diesel", features = ["sqlite"] }
diesel_codegen = { git = "https://github.com/SergioBenitez/diesel", default_features = false, features = ["sqlite"] }

View File

@ -1,11 +1,12 @@
#![feature(plugin, custom_derive, custom_attribute)]
#![plugin(rocket_codegen, serde_macros, diesel_codegen)]
#![feature(plugin, custom_derive, custom_attribute, rustc_macro)]
#![plugin(rocket_codegen, diesel_codegen)]
extern crate rocket;
extern crate serde_json;
#[macro_use] extern crate diesel;
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate rocket_contrib;
extern crate serde_json;
#[macro_use] extern crate serde_derive;
mod static_files;
mod task;