mirror of
https://github.com/rwf2/Rocket.git
synced 2025-01-30 05:12:13 +00:00
Allow head decorator and options via route decorator.
This commit is contained in:
parent
bad0c20cda
commit
2de006d9f9
@ -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);
|
||||
|
@ -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
|
||||
);
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ extern crate rocket;
|
||||
#[get("")]
|
||||
fn get() -> &'static str { "hi" }
|
||||
|
||||
fn main() {
|
||||
let _ = routes![get];
|
||||
}
|
||||
#[get("/")]
|
||||
fn get_empty() { }
|
||||
|
||||
fn main() { }
|
||||
|
28
codegen/tests/run-pass/methods.rs
Normal file
28
codegen/tests/run-pass/methods.rs
Normal file
@ -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() { }
|
Loading…
Reference in New Issue
Block a user