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:
parent
0ac0f0f504
commit
b807ae2796
87 changed files with 1497 additions and 1512 deletions
12
tests/ui/endpoint/async_state.rs
Normal file
12
tests/ui/endpoint/async_state.rs
Normal 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() {}
|
5
tests/ui/endpoint/async_state.stderr
Normal file
5
tests/ui/endpoint/async_state.stderr
Normal 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) {}
|
||||
| ^^^^^
|
11
tests/ui/endpoint/invalid_attribute.rs
Normal file
11
tests/ui/endpoint/invalid_attribute.rs
Normal 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() {}
|
11
tests/ui/endpoint/invalid_attribute.stderr
Normal file
11
tests/ui/endpoint/invalid_attribute.stderr
Normal 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
11
tests/ui/endpoint/self.rs
Normal 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() {}
|
19
tests/ui/endpoint/self.stderr
Normal file
19
tests/ui/endpoint/self.stderr
Normal 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
|
11
tests/ui/endpoint/too_few_args.rs
Normal file
11
tests/ui/endpoint/too_few_args.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
#[macro_use]
|
||||
extern crate gotham_restful;
|
||||
|
||||
#[derive(Resource)]
|
||||
#[resource(read)]
|
||||
struct FooResource;
|
||||
|
||||
#[read]
|
||||
fn read() {}
|
||||
|
||||
fn main() {}
|
11
tests/ui/endpoint/too_few_args.stderr
Normal file
11
tests/ui/endpoint/too_few_args.stderr
Normal 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
|
11
tests/ui/endpoint/too_many_args.rs
Normal file
11
tests/ui/endpoint/too_many_args.rs
Normal 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() {}
|
11
tests/ui/endpoint/too_many_args.stderr
Normal file
11
tests/ui/endpoint/too_many_args.stderr
Normal 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
|
11
tests/ui/endpoint/unknown_attribute.rs
Normal file
11
tests/ui/endpoint/unknown_attribute.rs
Normal 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() {}
|
11
tests/ui/endpoint/unknown_attribute.stderr
Normal file
11
tests/ui/endpoint/unknown_attribute.stderr
Normal 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
|
11
tests/ui/endpoint/unsafe.rs
Normal file
11
tests/ui/endpoint/unsafe.rs
Normal 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() {}
|
11
tests/ui/endpoint/unsafe.stderr
Normal file
11
tests/ui/endpoint/unsafe.stderr
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue