2018-10-05 04:44:42 +00:00
|
|
|
#[macro_use] extern crate rocket;
|
|
|
|
|
|
|
|
// Check a path is supplied, at least.
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get()]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn a0() {}
|
|
|
|
|
|
|
|
// Check that it only works on functions.
|
|
|
|
#[get("/")]
|
|
|
|
struct S;
|
|
|
|
|
|
|
|
#[get("/")]
|
|
|
|
enum A { }
|
|
|
|
|
|
|
|
#[get("/")]
|
|
|
|
trait Foo { }
|
|
|
|
|
|
|
|
#[get("/")]
|
|
|
|
impl S { }
|
|
|
|
|
|
|
|
// Check that additional parameter weirdness is caught.
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", 123)]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn b0() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", "/")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn b1() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get(data = "<foo>", "/")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn b2(foo: usize) {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", unknown = "foo")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn b3() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", ...)]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn b4() {}
|
|
|
|
|
|
|
|
// Check that all identifiers are named
|
|
|
|
|
|
|
|
#[get("/")]
|
2020-07-21 17:23:59 +00:00
|
|
|
fn c1(_: usize) {}
|
2018-10-05 04:44:42 +00:00
|
|
|
|
|
|
|
// Check that the path is a string, rank is an integer.
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get(100)]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn d0() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get('/')]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn d1() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", rank = "1")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn d2() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", rank = '1')]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn d3() {}
|
|
|
|
|
|
|
|
// Check that formats are valid media-type strings.
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", format = "applicationx-custom")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn e0() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", format = "")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn e1() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", format = "//")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn e2() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", format = "/")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn e3() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", format = "a/")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn e4() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", format = "/a")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn e5() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", format = "/a/")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn e6() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", format = "a/b/")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn e7() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", format = "unknown")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn e8() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", format = 12)]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn e9() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", format = 'j')]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn e10() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", format = "text//foo")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn e12() {}
|
|
|
|
|
|
|
|
// Check that route methods are validated properly.
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[route(CONNECT, "/")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn f0() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[route(FIX, "/")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn f1() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[route("hi", "/")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn f2() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[route("GET", "/")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn f3() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[route(120, "/")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn f4() {}
|
|
|
|
|
|
|
|
fn main() {}
|