resource static method

RouteGroupDefinition resource(
  1. String resource,
  2. Type controller, {
  3. String? parameterName,
})

Implementation

static RouteGroupDefinition resource(String resource, Type controller,
    {String? parameterName}) {
  resource = resource.toLowerCase();

  final resourceId =
      '${(parameterName ?? resource).toSingular().toLowerCase()}Id';

  return Route.group(resource, [
    Route.get('/', (controller, #index)),
    Route.get('/<$resourceId>', (controller, #show)),
    Route.post('/', (controller, #create)),
    Route.put('/<$resourceId>', (controller, #update)),
    Route.patch('/<$resourceId>', (controller, #update)),
    Route.delete('/<$resourceId>', (controller, #delete))
  ]);
}