diff --git a/codegen/src/decorators/route.rs b/codegen/src/decorators/route.rs index 7bf2bf01..26d79808 100644 --- a/codegen/src/decorators/route.rs +++ b/codegen/src/decorators/route.rs @@ -290,5 +290,8 @@ method_decorator!(get_decorator, Get); method_decorator!(put_decorator, Put); method_decorator!(post_decorator, Post); method_decorator!(delete_decorator, Delete); -method_decorator!(patch_decorator, Patch); method_decorator!(head_decorator, Head); +method_decorator!(patch_decorator, Patch); + +// TODO: Allow this once Diesel incompatibility is fixed. +// method_decorator!(options_decorator, Options); diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index cf7d8c94..68ca4cfb 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -160,5 +160,7 @@ pub fn plugin_registrar(reg: &mut Registry) { "delete" => delete_decorator, "head" => head_decorator, "patch" => patch_decorator + // TODO: Allow this once Diesel incompatibility is fixed. Fix docs too. + // "options" => options_decorator ); } diff --git a/codegen/src/parser/route.rs b/codegen/src/parser/route.rs index 98b324a2..07663869 100644 --- a/codegen/src/parser/route.rs +++ b/codegen/src/parser/route.rs @@ -134,8 +134,8 @@ impl RouteParams { fn is_valid_method(method: Method) -> bool { use rocket::http::Method::*; match method { - Get | Put | Post | Delete | Patch => true, - _ => false + Get | Put | Post | Delete | Head | Patch | Options => true, + Trace | Connect => false } } diff --git a/codegen/tests/run-pass/empty-fn.rs b/codegen/tests/run-pass/empty-fn.rs index 86b909f7..66ccad22 100644 --- a/codegen/tests/run-pass/empty-fn.rs +++ b/codegen/tests/run-pass/empty-fn.rs @@ -6,6 +6,7 @@ extern crate rocket; #[get("")] fn get() -> &'static str { "hi" } -fn main() { - let _ = routes![get]; -} +#[get("/")] +fn get_empty() { } + +fn main() { } diff --git a/codegen/tests/run-pass/methods.rs b/codegen/tests/run-pass/methods.rs new file mode 100644 index 00000000..24d41d61 --- /dev/null +++ b/codegen/tests/run-pass/methods.rs @@ -0,0 +1,28 @@ +#![feature(plugin)] +#![plugin(rocket_codegen)] + +extern crate rocket; + +#[get("/")] +fn get() { } + +#[put("/")] +fn put() { } + +#[post("/")] +fn post() { } + +#[delete("/")] +fn delete() { } + +#[head("/")] +fn head() { } + +#[patch("/")] +fn patch() { } + +// TODO: Allow this once Diesel incompatibility is fixed. +// #[options("/")] +// fn options() { } + +fn main() { }