mirror of https://github.com/rwf2/Rocket.git
Update serde in examples.
This commit is contained in:
parent
9cf23ae2d4
commit
920bd35d46
|
@ -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"
|
||||
|
|
|
@ -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,19 +27,15 @@ 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() => {
|
||||
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())
|
||||
}
|
||||
Error::NoRoute => {
|
||||
} else {
|
||||
format!("<p>Sorry, '{}' is not a valid path!</p>
|
||||
<p>Try visiting /hello/<name>/<age> instead.</p>",
|
||||
request.uri())
|
||||
}
|
||||
_ => format!("<p>Bad Request</p>"),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -8,7 +8,7 @@ workspace = "../../"
|
|||
rocket = { path = "../../lib" }
|
||||
rocket_codegen = { path = "../../codegen" }
|
||||
serde = "*"
|
||||
serde_macros = "*"
|
||||
serde_derive = "*"
|
||||
serde_json = "*"
|
||||
|
||||
[dependencies.rocket_contrib]
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -9,7 +9,7 @@ rocket = { path = "../../lib" }
|
|||
rocket_codegen = { path = "../../codegen" }
|
||||
serde = "*"
|
||||
serde_json = "*"
|
||||
serde_macros = "*"
|
||||
serde_derive = "*"
|
||||
lazy_static = "*"
|
||||
|
||||
[dependencies.rocket_contrib]
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"] }
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue