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

add derive macro for resource

This commit is contained in:
Dominic 2019-10-06 15:03:30 +02:00
parent 75c399d97a
commit 0cf7c9aa3a
Signed by: msrd0
GPG key ID: DCC8C247452E98F9
9 changed files with 132 additions and 15 deletions

View file

@ -17,7 +17,6 @@ gitlab = { repository = "msrd0/gotham-restful", branch = "master" }
fake = "2.2"
gotham = "0.4"
gotham_restful = { path = "../gotham_restful", features = ["openapi"] }
gotham_restful_derive = { path = "../gotham_restful_derive", features = ["openapi"] }
log = "0.4"
log4rs = { version = "0.8", features = ["console_appender"], default-features = false }
serde = "1"

View file

@ -1,5 +1,4 @@
#[macro_use] extern crate log;
#[macro_use] extern crate gotham_restful_derive;
use fake::{faker::internet::en::Username, Fake};
use gotham::{
@ -17,13 +16,19 @@ use log4rs::{
};
use serde::{Deserialize, Serialize};
rest_resource!{Users, route => {
route.read_all::<Self, _>();
route.read::<Self, _, _>();
route.create::<Self, _, _>();
route.update_all::<Self, _, _>();
route.update::<Self, _, _, _>();
}}
#[derive(Resource)]
#[rest_resource(ReadAll, Read, Create, DeleteAll, Delete, Update, UpdateAll)]
struct Users
{
}
// rest_resource!{Users, route => {
// route.read_all::<Self, _>();
// route.read::<Self, _, _>();
// route.create::<Self, _, _>();
// route.update_all::<Self, _, _>();
// route.update::<Self, _, _, _>();
// }}
#[derive(Deserialize, OpenapiType, Serialize)]
struct User