1
0
Fork 0
mirror of https://gitlab.com/msrd0/gotham-restful.git synced 2025-04-20 06:54:46 +00:00

Custom Endpoints

This commit is contained in:
msrd0 2021-01-18 16:56:16 +00:00
parent 002cfb1b4d
commit 5261aa9931
28 changed files with 524 additions and 46 deletions

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

View 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

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

View 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

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

View 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

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

View 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

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

View 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

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

View 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

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

View 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

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

View 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

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

View 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