mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-04-20 14:57:01 +00:00
Custom Endpoints
This commit is contained in:
parent
002cfb1b4d
commit
5261aa9931
28 changed files with 524 additions and 46 deletions
11
tests/ui/endpoint/custom_method_invalid_expr.rs
Normal file
11
tests/ui/endpoint/custom_method_invalid_expr.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
#[macro_use]
|
||||
extern crate gotham_restful;
|
||||
|
||||
#[derive(Resource)]
|
||||
#[resource(read_all)]
|
||||
struct FooResource;
|
||||
|
||||
#[endpoint(method = "I like pizza", uri = "custom_read")]
|
||||
async fn read_all() {}
|
||||
|
||||
fn main() {}
|
11
tests/ui/endpoint/custom_method_invalid_expr.stderr
Normal file
11
tests/ui/endpoint/custom_method_invalid_expr.stderr
Normal file
|
@ -0,0 +1,11 @@
|
|||
error: unexpected token
|
||||
--> $DIR/custom_method_invalid_expr.rs:8:21
|
||||
|
|
||||
8 | #[endpoint(method = "I like pizza", uri = "custom_read")]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error[E0412]: cannot find type `read_all___gotham_restful_endpoint` in this scope
|
||||
--> $DIR/custom_method_invalid_expr.rs:5:12
|
||||
|
|
||||
5 | #[resource(read_all)]
|
||||
| ^^^^^^^^ not found in this scope
|
11
tests/ui/endpoint/custom_method_invalid_type.rs
Normal file
11
tests/ui/endpoint/custom_method_invalid_type.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
#[macro_use]
|
||||
extern crate gotham_restful;
|
||||
|
||||
#[derive(Resource)]
|
||||
#[resource(read_all)]
|
||||
struct FooResource;
|
||||
|
||||
#[endpoint(method = "String::new()", uri = "custom_read")]
|
||||
async fn read_all() {}
|
||||
|
||||
fn main() {}
|
8
tests/ui/endpoint/custom_method_invalid_type.stderr
Normal file
8
tests/ui/endpoint/custom_method_invalid_type.stderr
Normal file
|
@ -0,0 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/custom_method_invalid_type.rs:8:21
|
||||
|
|
||||
8 | #[endpoint(method = "String::new()", uri = "custom_read")]
|
||||
| --------------------^^^^^^^^^^^^^^^-----------------------
|
||||
| | |
|
||||
| | expected struct `Method`, found struct `std::string::String`
|
||||
| expected `Method` because of return type
|
11
tests/ui/endpoint/custom_method_missing.rs
Normal file
11
tests/ui/endpoint/custom_method_missing.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
#[macro_use]
|
||||
extern crate gotham_restful;
|
||||
|
||||
#[derive(Resource)]
|
||||
#[resource(read_all)]
|
||||
struct FooResource;
|
||||
|
||||
#[endpoint(uri = "custom_read")]
|
||||
async fn read_all() {}
|
||||
|
||||
fn main() {}
|
13
tests/ui/endpoint/custom_method_missing.stderr
Normal file
13
tests/ui/endpoint/custom_method_missing.stderr
Normal file
|
@ -0,0 +1,13 @@
|
|||
error: Missing `method` attribute (e.g. `#[endpoint(method = "gotham_restful::gotham::hyper::Method::GET")]`)
|
||||
--> $DIR/custom_method_missing.rs:8:1
|
||||
|
|
||||
8 | #[endpoint(uri = "custom_read")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0412]: cannot find type `read_all___gotham_restful_endpoint` in this scope
|
||||
--> $DIR/custom_method_missing.rs:5:12
|
||||
|
|
||||
5 | #[resource(read_all)]
|
||||
| ^^^^^^^^ not found in this scope
|
11
tests/ui/endpoint/custom_uri_missing.rs
Normal file
11
tests/ui/endpoint/custom_uri_missing.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
#[macro_use]
|
||||
extern crate gotham_restful;
|
||||
|
||||
#[derive(Resource)]
|
||||
#[resource(read_all)]
|
||||
struct FooResource;
|
||||
|
||||
#[endpoint(method = "gotham_restful::gotham::hyper::Method::GET")]
|
||||
async fn read_all() {}
|
||||
|
||||
fn main() {}
|
13
tests/ui/endpoint/custom_uri_missing.stderr
Normal file
13
tests/ui/endpoint/custom_uri_missing.stderr
Normal file
|
@ -0,0 +1,13 @@
|
|||
error: Missing `uri` attribute (e.g. `#[endpoint(uri = "custom_endpoint")]`)
|
||||
--> $DIR/custom_uri_missing.rs:8:1
|
||||
|
|
||||
8 | #[endpoint(method = "gotham_restful::gotham::hyper::Method::GET")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0412]: cannot find type `read_all___gotham_restful_endpoint` in this scope
|
||||
--> $DIR/custom_uri_missing.rs:5:12
|
||||
|
|
||||
5 | #[resource(read_all)]
|
||||
| ^^^^^^^^ not found in this scope
|
11
tests/ui/endpoint/non_custom_body_attribute.rs
Normal file
11
tests/ui/endpoint/non_custom_body_attribute.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
#[macro_use]
|
||||
extern crate gotham_restful;
|
||||
|
||||
#[derive(Resource)]
|
||||
#[resource(read_all)]
|
||||
struct FooResource;
|
||||
|
||||
#[read_all(body = false)]
|
||||
async fn read_all() {}
|
||||
|
||||
fn main() {}
|
11
tests/ui/endpoint/non_custom_body_attribute.stderr
Normal file
11
tests/ui/endpoint/non_custom_body_attribute.stderr
Normal file
|
@ -0,0 +1,11 @@
|
|||
error: `body` can only be used on custom endpoints
|
||||
--> $DIR/non_custom_body_attribute.rs:8:12
|
||||
|
|
||||
8 | #[read_all(body = false)]
|
||||
| ^^^^
|
||||
|
||||
error[E0412]: cannot find type `read_all___gotham_restful_endpoint` in this scope
|
||||
--> $DIR/non_custom_body_attribute.rs:5:12
|
||||
|
|
||||
5 | #[resource(read_all)]
|
||||
| ^^^^^^^^ not found in this scope
|
11
tests/ui/endpoint/non_custom_method_attribute.rs
Normal file
11
tests/ui/endpoint/non_custom_method_attribute.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
#[macro_use]
|
||||
extern crate gotham_restful;
|
||||
|
||||
#[derive(Resource)]
|
||||
#[resource(read_all)]
|
||||
struct FooResource;
|
||||
|
||||
#[read_all(method = "gotham_restful::gotham::hyper::Method::GET")]
|
||||
async fn read_all() {}
|
||||
|
||||
fn main() {}
|
11
tests/ui/endpoint/non_custom_method_attribute.stderr
Normal file
11
tests/ui/endpoint/non_custom_method_attribute.stderr
Normal file
|
@ -0,0 +1,11 @@
|
|||
error: `method` can only be used on custom endpoints
|
||||
--> $DIR/non_custom_method_attribute.rs:8:12
|
||||
|
|
||||
8 | #[read_all(method = "gotham_restful::gotham::hyper::Method::GET")]
|
||||
| ^^^^^^
|
||||
|
||||
error[E0412]: cannot find type `read_all___gotham_restful_endpoint` in this scope
|
||||
--> $DIR/non_custom_method_attribute.rs:5:12
|
||||
|
|
||||
5 | #[resource(read_all)]
|
||||
| ^^^^^^^^ not found in this scope
|
11
tests/ui/endpoint/non_custom_params_attribute.rs
Normal file
11
tests/ui/endpoint/non_custom_params_attribute.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
#[macro_use]
|
||||
extern crate gotham_restful;
|
||||
|
||||
#[derive(Resource)]
|
||||
#[resource(read_all)]
|
||||
struct FooResource;
|
||||
|
||||
#[read_all(params = true)]
|
||||
async fn read_all() {}
|
||||
|
||||
fn main() {}
|
11
tests/ui/endpoint/non_custom_params_attribute.stderr
Normal file
11
tests/ui/endpoint/non_custom_params_attribute.stderr
Normal file
|
@ -0,0 +1,11 @@
|
|||
error: `params` can only be used on custom endpoints
|
||||
--> $DIR/non_custom_params_attribute.rs:8:12
|
||||
|
|
||||
8 | #[read_all(params = true)]
|
||||
| ^^^^^^
|
||||
|
||||
error[E0412]: cannot find type `read_all___gotham_restful_endpoint` in this scope
|
||||
--> $DIR/non_custom_params_attribute.rs:5:12
|
||||
|
|
||||
5 | #[resource(read_all)]
|
||||
| ^^^^^^^^ not found in this scope
|
11
tests/ui/endpoint/non_custom_uri_attribute.rs
Normal file
11
tests/ui/endpoint/non_custom_uri_attribute.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
#[macro_use]
|
||||
extern crate gotham_restful;
|
||||
|
||||
#[derive(Resource)]
|
||||
#[resource(read_all)]
|
||||
struct FooResource;
|
||||
|
||||
#[read_all(uri = "custom_read")]
|
||||
async fn read_all() {}
|
||||
|
||||
fn main() {}
|
11
tests/ui/endpoint/non_custom_uri_attribute.stderr
Normal file
11
tests/ui/endpoint/non_custom_uri_attribute.stderr
Normal file
|
@ -0,0 +1,11 @@
|
|||
error: `uri` can only be used on custom endpoints
|
||||
--> $DIR/non_custom_uri_attribute.rs:8:12
|
||||
|
|
||||
8 | #[read_all(uri = "custom_read")]
|
||||
| ^^^
|
||||
|
||||
error[E0412]: cannot find type `read_all___gotham_restful_endpoint` in this scope
|
||||
--> $DIR/non_custom_uri_attribute.rs:5:12
|
||||
|
|
||||
5 | #[resource(read_all)]
|
||||
| ^^^^^^^^ not found in this scope
|
11
tests/ui/endpoint/wants_auth_non_bool.rs
Normal file
11
tests/ui/endpoint/wants_auth_non_bool.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
#[macro_use]
|
||||
extern crate gotham_restful;
|
||||
|
||||
#[derive(Resource)]
|
||||
#[resource(read_all)]
|
||||
struct FooResource;
|
||||
|
||||
#[read_all(wants_auth = "yes, please")]
|
||||
async fn read_all() {}
|
||||
|
||||
fn main() {}
|
11
tests/ui/endpoint/wants_auth_non_bool.stderr
Normal file
11
tests/ui/endpoint/wants_auth_non_bool.stderr
Normal file
|
@ -0,0 +1,11 @@
|
|||
error: Expected boolean literal
|
||||
--> $DIR/wants_auth_non_bool.rs:8:25
|
||||
|
|
||||
8 | #[read_all(wants_auth = "yes, please")]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error[E0412]: cannot find type `read_all___gotham_restful_endpoint` in this scope
|
||||
--> $DIR/wants_auth_non_bool.rs:5:12
|
||||
|
|
||||
5 | #[resource(read_all)]
|
||||
| ^^^^^^^^ not found in this scope
|
Loading…
Add table
Add a link
Reference in a new issue