rocket-pinboard/src/main.rs

45 lines
987 B
Rust

#![feature(plugin)]
#![plugin(rocket_codegen)]
extern crate comrak;
extern crate glob;
extern crate inflector;
extern crate rocket;
extern crate rocket_contrib;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate serde_json;
mod handlers;
mod models;
use rocket::Rocket;
use std::sync::RwLock;
type NoteStore = RwLock<Vec<models::note::Note>>;
fn rocket(notes_path: Option<&str>) -> Rocket {
let notes = models::note::Note::load_all(notes_path);
rocket::ignite()
.manage(RwLock::new(notes))
.mount(
"/",
routes![handlers::home::index, handlers::static_files::all],
)
.mount(
"/notes",
routes![
handlers::note::index,
handlers::note::show_html,
handlers::note::show_json,
handlers::note::update
],
)
.attach(rocket_contrib::Template::fairing())
}
fn main() {
rocket(None).launch();
}