1
0
Fork 0
mirror of https://gitlab.com/msrd0/gotham-restful.git synced 2025-04-20 14:57:01 +00:00

Replace methods with more flexible endpoints

This commit is contained in:
msrd0 2021-01-18 00:05:30 +00:00
parent 0ac0f0f504
commit b807ae2796
87 changed files with 1497 additions and 1512 deletions

View file

@ -0,0 +1,12 @@
#[macro_use]
extern crate gotham_restful;
use gotham_restful::State;
#[derive(Resource)]
#[resource(read_all)]
struct FooResource;
#[read_all]
async fn read_all(state: &State) {}
fn main() {}

View file

@ -0,0 +1,5 @@
error: Endpoint handler functions that are async must not take `&State` as an argument, consider taking `&mut State`
--> $DIR/async_state.rs:10:19
|
10 | async fn read_all(state: &State) {}
| ^^^^^

View file

@ -0,0 +1,11 @@
#[macro_use]
extern crate gotham_restful;
#[derive(Resource)]
#[resource(read_all)]
struct FooResource;
#[read_all(FooResource)]
fn read_all() {}
fn main() {}

View file

@ -0,0 +1,11 @@
error: Invalid attribute syntax
--> $DIR/invalid_attribute.rs:8:12
|
8 | #[read_all(FooResource)]
| ^^^^^^^^^^^
error[E0412]: cannot find type `read_all___gotham_restful_endpoint` in this scope
--> $DIR/invalid_attribute.rs:5:12
|
5 | #[resource(read_all)]
| ^^^^^^^^ not found in this scope

11
tests/ui/endpoint/self.rs Normal file
View file

@ -0,0 +1,11 @@
#[macro_use]
extern crate gotham_restful;
#[derive(Resource)]
#[resource(read_all)]
struct FooResource;
#[read_all]
fn read_all(self) {}
fn main() {}

View file

@ -0,0 +1,19 @@
error: Didn't expect self parameter
--> $DIR/self.rs:9:13
|
9 | fn read_all(self) {}
| ^^^^
error: `self` parameter is only allowed in associated functions
--> $DIR/self.rs:9:13
|
9 | fn read_all(self) {}
| ^^^^ not semantically valid as function parameter
|
= note: associated functions are those in `impl` or `trait` definitions
error[E0412]: cannot find type `read_all___gotham_restful_endpoint` in this scope
--> $DIR/self.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)]
struct FooResource;
#[read]
fn read() {}
fn main() {}

View file

@ -0,0 +1,11 @@
error: Too few arguments
--> $DIR/too_few_args.rs:9:4
|
9 | fn read() {}
| ^^^^
error[E0412]: cannot find type `read___gotham_restful_endpoint` in this scope
--> $DIR/too_few_args.rs:5:12
|
5 | #[resource(read)]
| ^^^^ 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]
fn read_all(_id: u64) {}
fn main() {}

View file

@ -0,0 +1,11 @@
error: Too many arguments
--> $DIR/too_many_args.rs:9:4
|
9 | fn read_all(_id: u64) {}
| ^^^^^^^^
error[E0412]: cannot find type `read_all___gotham_restful_endpoint` in this scope
--> $DIR/too_many_args.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(pineapple = "on pizza")]
fn read_all() {}
fn main() {}

View file

@ -0,0 +1,11 @@
error: Unknown attribute
--> $DIR/unknown_attribute.rs:8:12
|
8 | #[read_all(pineapple = "on pizza")]
| ^^^^^^^^^
error[E0412]: cannot find type `read_all___gotham_restful_endpoint` in this scope
--> $DIR/unknown_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]
unsafe fn read_all() {}
fn main() {}

View file

@ -0,0 +1,11 @@
error: Endpoint handler methods must not be unsafe
--> $DIR/unsafe.rs:9:1
|
9 | unsafe fn read_all() {}
| ^^^^^^
error[E0412]: cannot find type `read_all___gotham_restful_endpoint` in this scope
--> $DIR/unsafe.rs:5:12
|
5 | #[resource(read_all)]
| ^^^^^^^^ not found in this scope