pub struct ResourceDef { /* private fields */ }Expand description
Resource definition that generates RESTful routes from a controller module
Generates 7 standard routes following Rails/Laravel conventions:
- GET /users -> index (list all)
- GET /users/create -> create (show create form)
- POST /users -> store (create new)
- GET /users/{id} -> show (show one)
- GET /users/{id}/edit -> edit (show edit form)
- PUT /users/{id} -> update (update one)
- DELETE /users/{id} -> destroy (delete one)
Route names are auto-generated: users.index, users.create, etc.
§Example
ⓘ
routes! {
resource!("/users", controllers::user),
resource!("/posts", controllers::post).middleware(AuthMiddleware),
resource!("/comments", controllers::comment, only: [index, show]),
}Implementations§
Source§impl ResourceDef
impl ResourceDef
Sourcepub fn middleware<M: Middleware + 'static>(self, middleware: M) -> Self
pub fn middleware<M: Middleware + 'static>(self, middleware: M) -> Self
Auto Trait Implementations§
impl Freeze for ResourceDef
impl !RefUnwindSafe for ResourceDef
impl Send for ResourceDef
impl Sync for ResourceDef
impl Unpin for ResourceDef
impl UnsafeUnpin for ResourceDef
impl !UnwindSafe for ResourceDef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more