mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-04-20 06:54:46 +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
|
@ -33,7 +33,7 @@ Use can look something like this (assuming the `auth` feature is enabled):
|
|||
# #[derive(Clone, Deserialize)]
|
||||
# struct MyAuthData { exp : u64 }
|
||||
#
|
||||
#[read_all(MyResource)]
|
||||
#[read_all]
|
||||
fn read_all(auth : AuthStatus<MyAuthData>) -> AuthSuccess<NoContent> {
|
||||
let auth_data = match auth {
|
||||
AuthStatus::Authenticated(data) => data,
|
||||
|
@ -102,7 +102,7 @@ Use can look something like this (assuming the `auth` feature is enabled):
|
|||
# #[derive(Clone, Deserialize)]
|
||||
# struct MyAuthData { exp : u64 }
|
||||
#
|
||||
#[read_all(MyResource)]
|
||||
#[read_all]
|
||||
fn read_all(auth : AuthStatus<MyAuthData>) -> AuthResult<NoContent, io::Error> {
|
||||
let auth_data = match auth {
|
||||
AuthStatus::Authenticated(data) => data,
|
||||
|
|
|
@ -21,8 +21,8 @@ the function attributes:
|
|||
# #[resource(read_all)]
|
||||
# struct MyResource;
|
||||
#
|
||||
#[read_all(MyResource)]
|
||||
fn read_all(_state: &mut State) {
|
||||
#[read_all]
|
||||
fn read_all() {
|
||||
// do something
|
||||
}
|
||||
# }
|
||||
|
|
|
@ -25,7 +25,7 @@ example that simply returns its body:
|
|||
#[resource(create)]
|
||||
struct ImageResource;
|
||||
|
||||
#[create(ImageResource)]
|
||||
#[create]
|
||||
fn create(body : Raw<Vec<u8>>) -> Raw<Vec<u8>> {
|
||||
body
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ struct MyResponse {
|
|||
message: &'static str
|
||||
}
|
||||
|
||||
#[read_all(MyResource)]
|
||||
fn read_all(_state: &mut State) -> Success<MyResponse> {
|
||||
#[read_all]
|
||||
fn read_all() -> Success<MyResponse> {
|
||||
let res = MyResponse { message: "I'm always happy" };
|
||||
res.into()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue