UseGuards class

Applies guards to a controller or endpoint.

Guards are special middleware that can prevent a request from being processed based on certain conditions. They are commonly used for authentication and authorization.

Example:

@Controller('/api/admin')
@UseGuards([AuthGuard, AdminGuard])
class AdminController {
  // All endpoints in this controller will be protected by AuthGuard and AdminGuard

  @Get('/stats')
  Future<Response> getStats(Request request) { ... }

  @Post('/settings')
  @UseGuards([SuperAdminGuard])
  // This endpoint will use AuthGuard, AdminGuard, and SuperAdminGuard
  Future<Response> updateSettings(Request request) { ... }
}

Constructors

UseGuards.new(List<Type> guards)
Creates a UseGuards annotation with the specified guard types.
const

Properties

guards List<Type>
The list of guard types to apply.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited