From b69527c39258d7e3522a2872a502466b3ce484e4 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Thu, 2 Feb 2017 15:02:32 -0800 Subject: [PATCH] Reenable the options decorator. --- codegen/src/decorators/route.rs | 4 +-- codegen/src/lib.rs | 6 ++--- codegen/tests/run-pass/methods.rs | 3 +-- examples/todo/README.md | 41 ++++++++++++++++++++----------- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/codegen/src/decorators/route.rs b/codegen/src/decorators/route.rs index aa837121..71f45ef3 100644 --- a/codegen/src/decorators/route.rs +++ b/codegen/src/decorators/route.rs @@ -314,6 +314,4 @@ method_decorator!(post_decorator, Post); method_decorator!(delete_decorator, Delete); method_decorator!(head_decorator, Head); method_decorator!(patch_decorator, Patch); - -// TODO: Allow this once Diesel incompatibility is fixed. -// method_decorator!(options_decorator, Options); +method_decorator!(options_decorator, Options); diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index e223c19d..02f7bb6a 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -16,6 +16,7 @@ //! * **delete** //! * **head** //! * **patch** +//! * **options** //! * **error** //! //! The grammar for all _route_ attributes, including **route**, **get**, @@ -173,9 +174,8 @@ pub fn plugin_registrar(reg: &mut Registry) { "post" => post_decorator, "delete" => delete_decorator, "head" => head_decorator, - "patch" => patch_decorator - // TODO: Allow this once Diesel incompatibility is fixed. Fix docs too. - // "options" => options_decorator + "patch" => patch_decorator, + "options" => options_decorator ); register_lints!(reg, RocketLint); diff --git a/codegen/tests/run-pass/methods.rs b/codegen/tests/run-pass/methods.rs index d74547a0..1fab7dd5 100644 --- a/codegen/tests/run-pass/methods.rs +++ b/codegen/tests/run-pass/methods.rs @@ -21,8 +21,7 @@ extern crate rocket; #[patch("/")] fn patch() { } #[route(PATCH, "/")] fn patch_r() { } -// TODO: Allow this once Diesel incompatibility is fixed. -// #[options("/")] fn options() { } +#[options("/")] fn options() { } #[route(OPTIONS, "/")] fn options_r() { } fn main() { } diff --git a/examples/todo/README.md b/examples/todo/README.md index 355cd6ab..1b3c7377 100644 --- a/examples/todo/README.md +++ b/examples/todo/README.md @@ -7,20 +7,31 @@ a result, you'll need to have `sqlite3` and its headers installed: * **Debian/Ubuntu:** `apt-get install libsqlite3-dev` * **Arch:** `pacman -S sqlite` -**Before running this example, you'll also need to ensure there's a database -file with the correct tables present.** On a Unix machine or with bash -installed, you can simply run the `boostrap.sh` script. The script installs the -`diesel_cli` tools if they're not already installed and runs the migrations. - -## Manually Running Migrations - -You can also run the migrations manually with the following commands: - -``` -cargo install diesel_cli # install diesel CLI tools -DATABASE_URL=db/db.sql diesel migration run # create db/db.sql -``` - ## Running -Run this example using: `DATABASE_URL=db/db.sql cargo run` +**Before running, building, or testing this example, you'll need to ensure the +following:** + + 1. A SQLite database file with the proper schema is present. + + On a Unix machine or with bash installed, you can simply run the + `boostrap.sh` script to create the database. The script installs the + `diesel_cli` tools if they're not already installed and runs the migrations. + The script will output a `DATABASE_URL` variable. + + You can also run the migrations manually with the following commands: + + ``` + cargo install diesel_cli # install diesel CLI tools + DATABASE_URL=db/db.sql diesel migration run # create db/db.sql + ``` + + 2. A `DATABASE_URL` environment variable is set that points to the SQLite + database file. + + Use the `DATABASE_URL` variable emitted from the `bootstrap.sh` script, or + enter it manually, as follows: + + * `DATABASE_URL=db/db.sql cargo build` + * `DATABASE_URL=db/db.sql cargo test` + * `DATABASE_URL=db/db.sql cargo run`