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

Merge branch 'master' into openapi

This commit is contained in:
Dominic 2019-09-30 20:16:27 +02:00
commit 24f8fd96db
Signed by: msrd0
GPG key ID: DCC8C247452E98F9
4 changed files with 44 additions and 18 deletions

View file

@ -1,5 +1,4 @@
#[macro_use] extern crate log;
#[macro_use] extern crate serde;
use fake::{faker::internet::en::Username, Fake};
use gotham::{
@ -16,13 +15,17 @@ use log4rs::{
encode::pattern::PatternEncoder
};
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, Serialize)]
struct User
{
rest_struct!{User {
username : String
}
}}
impl ResourceReadAll<Success<Vec<User>>> for Users
{
@ -90,18 +93,6 @@ impl ResourceDelete<u64, Success<()>> for Users
}
}
impl Resource for Users
{
fn setup<D : DrawResourceRoutes>(mut route : D)
{
route.read_all::<Self, _>();
route.read::<Self, _, _>();
route.create::<Self, _, _>();
route.update_all::<Self, _, _>();
route.update::<Self, _, _, _>();
}
}
const ADDR : &str = "127.0.0.1:18080";
fn main()