Reenable the options decorator.

This commit is contained in:
Sergio Benitez 2017-02-02 15:02:32 -08:00
parent ecc62beeac
commit b69527c392
4 changed files with 31 additions and 23 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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() { }

View File

@ -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`