#![feature(plugin)]
#![feature(custom_derive)]

// Rocket
#![plugin(rocket_codegen)]

extern crate rocket;
extern crate rocket_contrib;

// Serde
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;

// Chrono
extern crate chrono;

// Model
#[derive(Serialize, Deserialize, Debug)]
pub struct Person {
    pub id: i32,
    pub name: String,
    pub birthday: NaiveDateTime,
}

// View
use rocket::response::Failure;
use rocket_contrib::Json;
use chrono::prelude::*;

#[get("/person/<id>", format = "application/json")]
fn get_person(id: i32) -> Result<Json<Person>, Failure> {
    Ok(Json(Person {
        id,
        name: String::from("Max Musterman"),
        birthday: Local::now().naive_local(),
    }))
}

fn main() {
    rocket::ignite().mount("/", routes![
        get_person
    ]).launch();
}
